Macro Automation

Peteor

Board Regular
Joined
Mar 16, 2018
Messages
150
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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Peteor

Board Regular
Joined
Mar 16, 2018
Messages
150
Disregard. I found the Macro can open and close the file in a timely enough manner, that this would work.
 

Forum statistics

Threads
1,143,637
Messages
5,719,969
Members
422,252
Latest member
wannabegeek1

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
Top