ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Loop and autofill (https://www.excelbanter.com/excel-discussion-misc-queries/138724-loop-autofill.html)

CaroleO

Loop and autofill
 
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

Bernie Deitrick

Loop and autofill
 
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


"CaroleO" wrote in message
...
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





All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com