Elenico
IS-IT--Management
- Jan 31, 2008
- 1
Hi
I am new on vba so I would kindly ask for your help.
I am trying to select a variable range of cells. I know the starting
cell, it is fixed: B6 but the ending cell in the column B can be
changing depending on the data.
I would like to select the range and then perform certain action (fill
the non empty cells) until there are no empty cells in the range. I
would need to know
How to select this changing range?
How to perform the action only until there are no empty cells in the
range (I did it repeating it 40 times)
The code I have it is as follows,
Dim Cell As Object
Dim i As Integer
For i = 1 To 40
Sheets(1).Range("B6:B800").Select
For Each Cell In Selection
If Cell.Value = "" Then
Cell.Value = Cell.Offset(1, 0).Value
Else: End If
Next Cell
Next i
The range I hard-define it from B6 to B800 and the loop I said 40
times, but I would like that it just selects the necessary cells in
the real range and does the loop the necessary amount of times until
no empty cells are existing.
Hope you can help with this, this will be a great learning experience!
Thanks-Gracias!
I am new on vba so I would kindly ask for your help.
I am trying to select a variable range of cells. I know the starting
cell, it is fixed: B6 but the ending cell in the column B can be
changing depending on the data.
I would like to select the range and then perform certain action (fill
the non empty cells) until there are no empty cells in the range. I
would need to know
How to select this changing range?
How to perform the action only until there are no empty cells in the
range (I did it repeating it 40 times)
The code I have it is as follows,
Dim Cell As Object
Dim i As Integer
For i = 1 To 40
Sheets(1).Range("B6:B800").Select
For Each Cell In Selection
If Cell.Value = "" Then
Cell.Value = Cell.Offset(1, 0).Value
Else: End If
Next Cell
Next i
The range I hard-define it from B6 to B800 and the loop I said 40
times, but I would like that it just selects the necessary cells in
the real range and does the loop the necessary amount of times until
no empty cells are existing.
Hope you can help with this, this will be a great learning experience!
Thanks-Gracias!