Copy/Paste Formulas Based on Number of Rows of Data in a different worksheet

tebbdu

New Member
Joined
Jun 5, 2012
Messages
2
I have a worksheet that has about 40 columns where each cell is calculating a formula for a financial model.
Each formula references data in a separate worksheet.
How do I create a macro that will only fill the 40 formula cells based on the number of rows of data I have in a separate worksheet?

Formula Worksheet - Header row plus 40 columns of formulas in each row
Data worksheet - raw data; number of columns fluctuates every day

I have seen solutions based on a single formula, but not based on a very large number of formulas like I have.

Can someone help me please?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Sorry - I did not describe the problem very well.

I have a worksheet with formulas in 40 different columns across each row.
Each of these rows corresponds to a row of raw data in a separate worksheet in the same workbook.

The number of rows of raw data fluctuates daily - and rather than just paste the formulas down about 10,000 rows just to ensure I cover all of the raw data - can I write a macro that will calculate how many rows are in the raw data sheet and then paste the 40 columns of formulas to the same number of rows?
 
Upvote 0
hello tebbdu
the following code will tell you how many rows of data there are i am assuming your raw data
is on sheet2

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
x = Sheets("sheet2").Range("a" & Rows.Count).End(xlUp).Row
y=1
range("a" & y & ":an" & x) 'your formula here

End Sub

should get you started
cheers
kevin
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top