Loop and autofill

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Excel 2003 SR1

I have several columns with formulas in them (row 3). I recorded a macro
which autofills to a specific row.

Range("K1").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("J1:J55000"), Type:=xlFillDefault
Range("K1:K55000").Select

It would be better (since the number of rows changes with each new file), to
test on if a cell in column A = blank, stop the autofill. I've just
discovered Do While ...Loop, but am not clear where it captures the formula.
Do I put the formula (ex - =IF(AND(K3>"0",K3<"A"),K3,N2) below the Do While
Column A <>"", or refer to the cell with the formula in it?

TIA,

CaroleO
 
Carole,

No need to loop:

Range(Range("J2"), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 10)).Formula = _
"=IF(AND(K3>""0"",K3<""A""),K3,N2)"

HTH,
Bernie
MS Excel MVP
 
Back
Top