#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Loop Heather O'Malley Excel Discussion (Misc queries) 1 November 6th 06 02:39 PM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM
for-each-next loop Valeria[_2_] Excel Programming 2 December 2nd 03 02:58 PM


All times are GMT +1. The time now is 08:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"