Trying to run a macro in another workbook

JKK22

New Member
Joined
Oct 12, 2022
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hello, I need data from another workbook updated, before doing another process.
I created the below macro in my current workbook , to open up the other workbook, run the macro called "GetPSDataMon" within that other workbook, and close that other workbook.
It opens up the workbook fine, but it won't run the macro

Sub Update0901Fri()

Dim fileName As String
nPath = "\\Swib\root\ShrIOFAFinance\SIF\SIF Earnings\"
fileNameString = "09.1 AveBalRecalc" & ".xlsm"
fileName = Dir(nPath & fileNameString)

Workbooks.Open nPath & fileName
Sheets("Running_Report").Select
Call GetPSDataMon
Workbooks(fileName).Save
Workbooks(fileName).Close
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi JKK22,

try

VBA Code:
Application.Run ("'" & fileName & "'!GetPSDataMon")

Ciao,
Holger
 
Upvote 0
Solution
Hello
This worked! I removed: Call GetPSDataMon
and replaced it with : Application.Run ("'" & fileName & "'!GetPSDataMon")

thank you
 
Upvote 0
Hi JKK22,

glad we could help on this one.

Holger
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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