How do I pass the Sheet Name as an argument from a Form button?

StaffsLebowski

New Member
Joined
Nov 18, 2009
Messages
22
Hi,

I have a Form Button (not Command button) on a sheet and want to call a global function. Something like this:

MyFile.xlsm!MyFunction(Sheet.Name)

How do I do this using the Assign Macro dialog box?

Thank you for your help

StaffsLebowski
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Given that the sheet has to be active for you to press the button, you could simply use activesheet.name in the called code?
 
Upvote 0
Hi Rory, and thanks for your reply

That's true and a workaround, but doesn't give me the answer I want.

I have a global function I want to call from anywhere, using a passed sheet name. In this instance, the function is being called from a button so, I'd like to know, in this example, is it possible?
 
Upvote 0
Rich (BB code):
Public Sub Button1_Click()
    MyFunction ActiveSheet.Name
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,900
Members
449,194
Latest member
JayEggleton

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