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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,215,606
Messages
6,125,803
Members
449,261
Latest member
Rachel812321

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