Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Do Loop
I'd like to loop through column 3 of my datafile to find all empty cells in this field. Because I'd like to loop down through each row I've created an iLastRow variable so that the loop can Do Until it reaches iLastRow. The bit I'd like some help with is.. The empty cells can be identified in two ways, either that they are empty, so you could say do until is empty or that they have a colourindex of 15, whichever is more efficient. Then.... Where VBA finds a cell matching this criteria, I need to grab the contents from the cell above to populate the 'found' cell. Does this make sense? That way all my fields in column 3 will be populated with a value so I can run an autofilter against it. Can anyone kindly help with the syntax? Many thanks Jacqui |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Do Loop
Jacqui,
Sub test() Dim i As Long, lngLastRow As Long With Sheet1 lngLastRow = .Cells(Rows.Count, 3).End(xlUp).Row For i = 2 To lngLastRow 'assuming cell 1 is always populated If .Cells(i, 3).Value = "" Then .Cells(i, 3).Value = .Cells(i - 1, 3).Value Next End With End Sub Rob "jacqui" wrote in message ... I'd like to loop through column 3 of my datafile to find all empty cells in this field. Because I'd like to loop down through each row I've created an iLastRow variable so that the loop can Do Until it reaches iLastRow. The bit I'd like some help with is.. The empty cells can be identified in two ways, either that they are empty, so you could say do until is empty or that they have a colourindex of 15, whichever is more efficient. Then.... Where VBA finds a cell matching this criteria, I need to grab the contents from the cell above to populate the 'found' cell. Does this make sense? That way all my fields in column 3 will be populated with a value so I can run an autofilter against it. Can anyone kindly help with the syntax? Many thanks Jacqui |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find loop doesn't loop | Excel Discussion (Misc queries) | |||
Loop | Excel Discussion (Misc queries) | |||
Worksheet_Change - loop within a loop | Excel Programming | |||
HELP!!!! Can't stop a loop (NOT an infinite loop) | Excel Programming | |||
for-each-next loop | Excel Programming |