Why are some macros available to assign to a button and others aren't

billfinn

Board Regular
Joined
Jun 7, 2018
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
I am trying to assign a button to a new macro. I tried to insert the macro into the workbook but it ended up in the project every time. I am unable to assign the button. I would appreciate it if anyone has a link or info or an article or something that I could educate myself with in terms of macros in the project vs the workbook vs the worksheet. Trying to get myself re-educated and it's a slow process.
Thanks much,
Bill
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Assuming that your button is a forms control button (or a shape) then I would tend to put the code in a regular module.
To assign the macro to a button it cannot start with "Private Sub"
 
Upvote 0
It doesn't begin with Private Sub, and it is a Form Control buttom
Can you tell me what you mean by a regular module? Is that neither a workbook module or a worksheet module?
Also, I neglected to include the code - simple enough but I can't make the button operate it
Code:
Sub Filename_CellValue()Dim Path As String
Dim filename As String
Path = "H:\Estimator\Estimates\"
filename = Range("F14")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled


MsgBox "The new Estimate number is " & filename
End Sub
thanks much for the response!
Bill
 
Last edited:
Upvote 0
Fluff,
Thanks very much for the reference! From what I read there I can take any macro I want to create and assign it to the workbook if the activity takes place in the workbook. I'm having heck of a time doing just that. Maybe I'll delete it and start fresh, see what that does for me..
Again, thank you. I have saved that link and will refer to it as required.
Bill
 
Upvote 0
Quick update;
I deleted the module and started from scratch. For some reason it showed up as 'Estimator Master Copy.xlsm'! Create_New_Estimate.Create_New_Estimate in the choices shown in the Assign Macro window but I'm just happy it showed up and I was able to assign a button to it.
Thanks again for the info!
Bill
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0
Bill

Don't use the same name for a sub as you've used for a module, or any other object for that matter.
 
Upvote 0
Thanks Norie!
I do try to always use distinctly different names but I appreciate the reminder!
Bill
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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