Referring back to calling spreadsheet from presonal.xlsb

ijourneaux

New Member
Joined
Jul 9, 2018
Messages
38
I have a bunch of macros that I keep in a personal.xlsb spreadsheet so they are avaialble to all of the workbook I use.

When in a macro in personal.xlsb, I refer back to the calling spreadsheet using activeworkbook.

That works as long as I only have 1 spreadsheet up but if I am using excel and have several workbooks open, the macros can break if the wrong workbook is active.

Is there a way from Personal.xlsb to refer back to the specific spreadsheet that called the macro?

Ian
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
What I do is to pass an identifying variable from the calling macro to the one being called

Away from PC, so untested and from memory, something along these lines ...

In workbook where you are running the macro
Code:
Private Sub CommandButton1_Click()
    Call MyMacro(ThisWorkbook)
End Sub

In Personal workbook
Code:
Sub MyMacro(wb As Workbook)
    MsgBox "WhoCalledThis = " & wb.Name
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

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