Using a macro in other workbooks

mack321

New Member
Joined
Sep 15, 2015
Messages
39
So, I have a macro that works beautifully when saved in the workbook it is being used in but when I try to move it to my Personal macro workbook or even to a resident workbook in my C drive and call it from a new workbook, it will not run. It doesn't error out, it just does nothing. What am I missing?
I have others that work across any/all workbooks beautifully... just this one.

Sub Insert_Formula()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Activate
Range("$J$2").Formula = "=MID($C$6,FIND(""Customer Ord No:"",$C$6)+17,FIND("", R"",$C$6)-FIND(""Customer Ord No:"",$C$6)-17)"
Next
End Sub

Also, note that each workbook I am running this in is identical in layout and format.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Change:
ThisWorkbook.Worksheets

to:

ActiveWorkbook.Worksheets

Then put the macro in your Personal.xlsb workbook and remove it from all other workbooks. Now you should be able to run it on any workbook that is active by adding a button to your Quick-Access Toolbar to trigger it.
 
Upvote 0

Forum statistics

Threads
1,216,116
Messages
6,128,933
Members
449,480
Latest member
yesitisasport

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