#1   Report Post  
Cathy U
 
Posts: n/a
Default Fill Formula - Macro

I am creating a Macro which sorts and adds a formula to the right of a
column. I want to be able to fill down the data, without creating a range
because the number of rows can change. I want the formula to fill down to
the last active cell in the column on the left of the formula. Is there a
shortcut key I can use when recording the macro?

Thanks.
Cathy U
  #2   Report Post  
galimi
 
Posts: n/a
Default

Cathy,

Programmatically you can obtain the last active cell in a column with the
VBA command

sheet1.UsedRange.Columns(1).cells.count

Replace sheet1 with the sheet object you are referencing and the number 1
embedded in parentheses with the column number you are referencing. This
will give you the total number of used rows in that column.

http://HelpExcel.com

"Cathy U" wrote:

I am creating a Macro which sorts and adds a formula to the right of a
column. I want to be able to fill down the data, without creating a range
because the number of rows can change. I want the formula to fill down to
the last active cell in the column on the left of the formula. Is there a
shortcut key I can use when recording the macro?

Thanks.
Cathy U

  #3   Report Post  
Gord Dibben
 
Posts: n/a
Default

Cathy

Adjust to suit.

Sub Auto_Fill()
Dim lrow As Long
With ActiveSheet
lrow = Range("B" & Rows.Count).End(xlUp).Row
Range("C1:C" & lrow).FillDown
End With
End Sub


Gord Dibben Excel MVP

On Tue, 22 Feb 2005 07:25:10 -0800, "Cathy U" <Cathy
wrote:

I am creating a Macro which sorts and adds a formula to the right of a
column. I want to be able to fill down the data, without creating a range
because the number of rows can change. I want the formula to fill down to
the last active cell in the column on the left of the formula. Is there a
shortcut key I can use when recording the macro?

Thanks.
Cathy U


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
Fill formulas down in macro hhunt Excel Discussion (Misc queries) 2 February 17th 05 09:03 PM
Can you enter a formula in a cell to run a macro? Nevaeh Excel Worksheet Functions 2 February 14th 05 11:51 PM
Excel - formula to calculate colored fill cells within a range wi. MA Excel Worksheet Functions 1 January 7th 05 04:06 PM
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM


All times are GMT +1. The time now is 09:19 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"