Macro in Template Help: Need code that changes per new workbook name

asanj

New Member
Joined
Jul 13, 2017
Messages
1
I am currently struggling to find a code that will allow my macro to function properly when opening a new workbook form my excel template. The issue im having is that the consolidate function I am using is referencing the template file and not the new workbook-where the new info will be input. Below is the code, I would need the red area to be dynamic and change per new workbook name, the sheet in the workbook will be the same name so "New Data" shouldnt be an issue. Thanks

Range("A4").Select
Selection.Consolidate Sources:= _
"'G:\Interns\Aevin Sanjay\[Model Template Update.xltm]New Data'!R5C5:R203C7", _
Function:=xlSum, TopRow:=False, LeftColumn:=True, CreateLinks:=False
ActiveWindow.SmallScroll Down:=0
Range("H4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Admin 2").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,214,543
Messages
6,120,123
Members
448,947
Latest member
test111

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