Need to run a macro on all open workbooks

josephjeffery

New Member
Joined
Jul 29, 2013
Messages
5
I have a macro which fetches the input from the user once it runs and based on that input it does some activites.

All i need is am running the macro in the first workbook and giving the inputs..Based on the inputs given the macro should run the same on all the other workbooks which is open

Help on the same
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I have a macro which fetches the input from the user once it runs and based on that input it does some activites.

All i need is am running the macro in the first workbook and giving the inputs..Based on the inputs given the macro should run the same on all the other workbooks which is open

Help on the same


From the attempt at English above...

If the same action needs to be taken on all the open workbooks, that's easy - but it sounds like you need different workbooks to have different things done to them? "Based on the inputs given, the macro should..."

If it's just the same action on every open workbook, then encase your code like this:

Code:
Sub YourSubroutineName()

For each wb in Application.workbooks

'You code goes here

'But as we can't see your script, there's no way of knowing what action it will take. So either replace all references in your code to a sheet, ie 'sht1.range(...' with 'wb.sht1.range(...'

Next
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,795
Members
449,468
Latest member
AGreen17

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