Run a Macro within a Macro

smashclash

Board Regular
Joined
Nov 24, 2003
Messages
126
Office Version
  1. 365
Platform
  1. Windows
I have a macro that performs tasks for a sheet. (Call it macro "X" for reference.) I have another macro (reference name Macro "Y") that runs macro "X" for every excel workbook that is open. I set this up in another workbook but want to transfer into my personal macro's file.

I copied everything into my file but when I try to run macro Y it gets an error because it can't find macro X. How do I tell Macro Y where to find macro X?


This is what the macro looked like before I moved the data:

Sub HideALL()
For Each wb In Workbooks
If wb.Name <> ThisWorkbook.Name Then
Windows(wb.Name).Activate ' new line - activate the wb first
Application.Run ("VeryHidden.xls!Hideone")
End If
Next wb
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
If both macros are in the same workbook, all you should need is to call HideOne without any other mumbo jumbo.

Code:
    HideOne
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

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