View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Formula fill down

how about something like this, without selecting anything?

Option Explicit
Sub test()
Dim LastRow As Long
LastRow = Worksheets("Sheet1").Cells(Rows.Count, "i").End(xlUp).Row

Range("J2").Formula = "=IF(i2 24, ""Greater than 24 Hours"", ""Less than 24
Hours"")"
Range("J2").AutoFill Range("j2:j" & LastRow)

End Sub

--


Gary


"dan" wrote in message
oups.com...
Hi,

I am using this part of a macro to enter a formula into J2 and then
fill it down. However, the amount of rows differs and I only want to
fill it down to the last row.

Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]24, ""Greater than 24 Hours"", ""Less than 24
Hours"")"
Range("I2:J701").Select
Selection.FillDown

How can I have it know what the last row is and stop there?

Thanks!!!