Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 15
Default Formula fill down

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!!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Formula fill down

Change Range("I2:J701").Select to
Range("I2", Range("J2").End(xlDown)).Select

Charles
xl Geek
dan wrote:
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!!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
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!!!



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
formula fill down Pezcore Excel Discussion (Misc queries) 4 May 10th 08 06:17 PM
Fill formula from VBA Archie[_6_] Excel Programming 7 June 2nd 06 10:30 PM
Formula Fill help Josh O. Excel Worksheet Functions 1 May 12th 06 09:46 PM
Can't fill XL Formula in VBA Lift Off[_4_] Excel Programming 3 April 16th 04 12:08 AM
Using VB to fill a formula down eli silverman Excel Programming 1 October 27th 03 03:52 PM


All times are GMT +1. The time now is 04:40 PM.

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"