#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default 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



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
vba loop Jackie Excel Discussion (Misc queries) 4 February 28th 06 04:20 AM
Which loop to use theguz Excel Discussion (Misc queries) 2 August 5th 05 07:01 PM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
Help with a Loop Richard S Excel Discussion (Misc queries) 3 April 4th 05 01:42 PM
Help With Loop Dennis Excel Worksheet Functions 2 February 1st 05 08:04 AM


All times are GMT +1. The time now is 12:47 AM.

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"