problem running a macro from another macro in a different workbook

jsucsy

New Member
Joined
Jun 5, 2008
Messages
2
I'm writing a macro (macro A, WrapUp) to, among other things, run a macro (macro B, Browse_Print_Start) from a different sheet. Macro B is on a protected worksheet that I do not have the password for, but runs fine as a standalone. I can open the worksheet for Macro B, enter my variables, and click a button on the sheet to run the macro. However, when I try to call macro B from macro A, I get a "1004" error. Some of the code that I am trying to use to run this (irrelevant code removed):


Sub WrapUp()
FundName = Range("A4")
GainLossPages = Range("D4")
AppraisalPages = Range("E4")
RunDate = Range("B4")

RunExtract

End Sub

Sub RunExtract()

Application.DisplayAlerts = False

Workbooks.Open "1777_CMOD_Extract_Flexible(1) Custom for PWC Wrapup.xls"

Application.DisplayAlerts = True


Sheets("Flex Request Table").Select
Range("F10").Value = FundName
Range("F11").Value = FundName
Range("H10").Value = RunDate
Range("H11").Value = RunDate
Range("X10").Value = GainLossPages
Range("X11").Value = AppraisalPages

Application.Run "Browse_Print_Start"

'Call "1777_CMOD_Extract_Flexible(1) Custom for PWC Wrapup.xls!Browse_Print_Start"

'Application.Run "1777_CMOD_Extract_Flexible(1) Custom for PWC Wrapup!Browse_Print_Start"
'Application.Run ("Browse_Print_Start")
'"1777_CMOD_Extract_Flexible(1) Custom for PWC Wrapup.xls'!Extract_CMOD"


End Sub


I've also shown some of the other things I've tried that are now commented out. Anyone have any suggestions or workarounds for this? Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
If the procedure, "Browse_Print_Start", is Private, you can still use Application.Run. However, you will need to provide the parent codename of the worksheet. Replace, "SheetNameHere", with the correct worksheet name(text displayed in worksheet tab)...

Application.Run Sheets("SheetNameHere").CodeName & ".Browse_Print_Start"


...or simply use the codename. Assuming that the codename is Sheet1:

Application.Run "Sheet1.Browse_Print_Start"
 
Upvote 0
Great, thanks for the help. I ended up going a different direction with the macro, but I just came back and added this section for added functionality. This worked just fine.
 
Upvote 0

Forum statistics

Threads
1,214,566
Messages
6,120,262
Members
448,953
Latest member
Dutchie_1

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