Do within an If statement

T

Tempy

Hi, Tom Ogilvy gave me the following code, which works great. the
problem i have is that as it loops down it must check if the ActiveCell
is empty, if yes then do the Vlookup, if not then move one cell down to
the next empty cell.
My spreadsheet has +/- 5000 rows but must only apply the Vlookup to the
empty cells in column X.

Range("X1").Select
Do
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-23],LCS_Complete_E90.xls!C1:C12,2,0)"
ActiveCell.NumberFormat = "dd-mmm-yy"
activeCell.Offset(1,0).Select
Loop until isempty(activecell.offset(0,-23))

Could somebody please help me out of my misary ?

Tempy
 
B

Bob Phillips

Range("X1").Select
Do
if activecell.value = "" Then
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-23],LCS_Complete_E90.xls!C1:C12,2,0)"
ActiveCell.NumberFormat = "dd-mmm-yy"
End If
activeCell.Offset(1,0).Select
Loop until isempty(activecell.offset(0,-23))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top