Macro to insert formula into an existing worksheet when new worksheet added?

jtrib84

New Member
Joined
Mar 6, 2009
Messages
3
does anyone know if i can run a macro that will insert a formula into an existing worksheet that pulls information from a newly added worksheet? the existing worksheet will be a summary of all the newly created worksheet. all of the new worksheets will be the same template.

thanks!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Something like this in the ThisWorkbook module of your workbook (in the VB Editor).

(This is an example since you don't say what you want your formula to do).

Press Alt+F11 to go the VBEditor.

In the Project Explorer window, navigate to the ThisWorkbook module of your workbook. Double click that and paste this into the code window:
Code:
Private Sub Workbook_NewSheet(ByVal Sh As Object)
Dim strSum As String
strSum = "=SUM(" & Sh.Name & "!R1C1:R10C1)"
Worksheets("Master Sheet").Range("A1").FormulaR1C1 = strSum
End Sub

Hope that gets you started.
 
Upvote 0

Forum statistics

Threads
1,206,826
Messages
6,075,094
Members
446,119
Latest member
BrianAndrews

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