Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 124
Default Fill formula down using macro

hi, using VBA I would like to fill a formula down to end of my data rather
than to a fixed cell as the size of my data is different each time I run my
macro.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Fill formula down using macro

Const formulaStartingCell As String = "C2"
Dim lastrow As Long
'replace A to the column that will always be the last row
lastrow = Range("A" & Rows.Count).End(xlUp).Row

Range(formulaStartingCell).Activate
Selection.AutoFill Destination:=Range(formulaStartingCell & ":C" &
lastrow), Type:=xlFillDefault

"Charles" wrote:

hi, using VBA I would like to fill a formula down to end of my data rather
than to a fixed cell as the size of my data is different each time I run my
macro.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Fill formula down using macro

Hi,

Here is one example which puts the formula in all the cells

LastCell = [A1].End(xlDown).Row
Range([B1], "B" & LastCell) = "=COUNTIF(INDIRECT(R1C&""!A1:D10""),RC1)"

Note this is not a fill down command it puts the formula of interest in all
the cells indicated.

Cheers,
Shane Devenshire


"Charles" wrote:

hi, using VBA I would like to fill a formula down to end of my data rather
than to a fixed cell as the size of my data is different each time I run my
macro.

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
Macro Formula for counting rows and doing a fill in afterwards Bud Excel Worksheet Functions 0 September 25th 08 08:10 PM
Copy or Fill Down Macro? Chuck Excel Discussion (Misc queries) 4 October 9th 07 09:11 AM
Fill Blanks Macro LLoraine Excel Discussion (Misc queries) 2 August 29th 07 03:12 PM
Macro or Custom button to fill in the same formula TJ Excel Worksheet Functions 4 March 15th 06 10:33 PM
Fill Formula - Macro Cathy U Excel Discussion (Misc queries) 2 February 22nd 05 04:48 PM


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