Loop and autofill

C

CaroleO

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
 
B

Bernie Deitrick

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
 

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