ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   excel macro-copy formula to entire column? (https://www.excelbanter.com/excel-discussion-misc-queries/129982-excel-macro-copy-formula-entire-column.html)

kfboudreau

excel macro-copy formula to entire column?
 
i have a large amount of data i need to graph each week. The amount of data
varies each week. I would like to have a macro which creates a formula and
puts it in an adjacent cell to all the rows with data. I have created macros
for this, but it always pastes the formula in the number of rows i had in the
spreadsheet when i created the macro.

For instance, when i record the macro i had 32000 rows. It pastes the
formula in rows 2-32,000. When i pul in new data with 31000 rows, it is still
pasting the formula in rows 2-32,000. How do I get the macro to only paste in
the relative rows?
Thanks.

Gord Dibben

excel macro-copy formula to entire column?
 
With your formula entered in C1..............

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


Gord Dibben MS Excel MVP


On Fri, 9 Feb 2007 06:56:01 -0800, kfboudreau
wrote:

i have a large amount of data i need to graph each week. The amount of data
varies each week. I would like to have a macro which creates a formula and
puts it in an adjacent cell to all the rows with data. I have created macros
for this, but it always pastes the formula in the number of rows i had in the
spreadsheet when i created the macro.

For instance, when i record the macro i had 32000 rows. It pastes the
formula in rows 2-32,000. When i pul in new data with 31000 rows, it is still
pasting the formula in rows 2-32,000. How do I get the macro to only paste in
the relative rows?
Thanks.



kfboudreau

excel macro-copy formula to entire column?
 
Thanks for the assistance. It worked out great!

"kfboudreau" wrote:

i have a large amount of data i need to graph each week. The amount of data
varies each week. I would like to have a macro which creates a formula and
puts it in an adjacent cell to all the rows with data. I have created macros
for this, but it always pastes the formula in the number of rows i had in the
spreadsheet when i created the macro.

For instance, when i record the macro i had 32000 rows. It pastes the
formula in rows 2-32,000. When i pul in new data with 31000 rows, it is still
pasting the formula in rows 2-32,000. How do I get the macro to only paste in
the relative rows?
Thanks.



All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com