+ Reply to Thread
Results 1 to 6 of 6

Can't Select Macro Name for Button

  1. #1
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Can't Select Macro Name for Button

    Hello,

    I am trying to assign a macro to a button. After clicking “Assign Macro,” the name that appears in the Macro Name field is the name of the document that I’m adding the button to. I then select the macro name I want to assign to the button. This name now appears in the Macro Name field, and I click OK. The trouble I’m running into is that the macro name does not save because when I reopen the Assign Macro box again the file name appears in the Macro Name field again, not the macro name I just selected. Does anyone know why this is happening? Thank you!

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Can't Select Macro Name for Button

    .
    .
    It sounds like you might not be assigning the macro properly ?

    Go to the DEVELOPER TAB / INSERT ... click it.

    In the upper left hand corner is the graphic for a Command Button ... click it.

    Place your cursor on the sheet approximately where you want the button positioned (you can move it late if necessary).

    Left click the mouse. The button is on the sheet and another window opens with macro names showing.

    Left click the macro name you want .. Click OK.

    Done.


    When you return to the Macro Assign window, the macro name appearing in the Macro Name Field might not necessarily be the macro you expect. If your macro was assigned to the button once,
    it will stay that way until you change it.

    If the assigned macro is truly changing without your help, you either have a corrupted workbook or a bad install of Excel that needs repair ?

  3. #3
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Re: Can't Select Macro Name for Button

    I am a beginner so it is very possible that I was not assigning the macro properly. I followed your steps (for which I thank you for being so thorough), and still the macro name did not appear in the Macro Name field. Taking your suggestion that the file may be corrupted, I created a new Excel file, followed your steps, and this time the macro name assigned did not change, so it would seem that the file is indeed corrupted. Big bummer on the one hand, but on the other hand at least I now know what the problem is. Thank you very much for your help . . . . it is much appreciated!

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Can't Select Macro Name for Button

    Before you start over ... if your Macro Name begins with Private Sub bla bla bla ()

    the word PRIVATE will prevent the macro from being seen in the Macro List.

    If you remove the PRIVATE from the beginning of the macro name, it will show in the list.


    To keep the macro private and still run it, if your button is named CommandButton1 ... you would need to change your macro name to :

    Private Sub CommandButton1_Click()
    'your code
    End Sub

    If you've given the button a specific name ...

    Private Sub YourButtonNameHere_Click ()
    'your code
    End Sub


    Hope that makes sense.


    ps: The purpose of using PRIVATE at the beginning of a Sub is to insure someone who likes to snoop around and mess things up, can't find the sub. It's hidden / Private from their view.
    If they know anything about Excel and VBA, using Private won't stop them.

  5. #5
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Re: Can't Select Macro Name for Button

    Thank you. Off hand I don't remember if PRIVATE is in the code, but I will check tomorrow when I return to work. Here's to keeping my fingers crossed. Your directions do make sense and, if anything, may come in handy for another time. Again, thank you for your time . . . still appreciating your thoroughness!

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: Can't Select Macro Name for Button

    Ok. Here's to hoping for the best !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Form - select button & retrieve button name or button's caption
    By lexusap in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-27-2016, 12:28 AM
  2. Replies: 3
    Last Post: 01-07-2015, 12:19 PM
  3. [SOLVED] Select column A's cell in relation to the row that macro button was clicked on?
    By xlyfe in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-09-2013, 12:24 PM
  4. Select active X option button and drop down in a another excel file using macro
    By vishal_dhami in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2012, 07:20 AM
  5. Macro to select/tick certain ActiveX OptionButton (radio button)
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2011, 08:40 AM
  6. Run Macro, but don't select button
    By mattmdf in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-09-2008, 12:48 PM
  7. [SOLVED] select toolbar button from macro
    By jasminesy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2006, 03:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1