Macro Automation

Peteor

Board Regular
Joined
Mar 16, 2018
Messages
152
Team,

I am building a macro that consolidates a substantial amount of information. While building I realized "This can be easier", so here I am.........

I would like to be able to run the macro without having to open the file which has the "Index" Worksheet. How do I accomplish this? The ONLY section of my macro that requires the opening of the file is provided below. How do I get around the Activate functions?

FileName = Dir(PathName & "\" & "*.xls*")
FileName_No_Extension = Left(FileName, Len(FileName) - 4)

Set Rng = Workbooks(FileName_No_Extension).Sheets("Index").Range("B5:B1000")

Workbooks(FileName_No_Extension).Activate
Worksheets("Index").Activate
With ActiveSheet
LastCol = .Cells(4, .Columns.Count).End(xlToLeft).Column
End With
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Disregard. I found the Macro can open and close the file in a timely enough manner, that this would work.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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