+ Reply to Thread
Results 1 to 5 of 5

Adding button text change function to existing macro

  1. #1
    Forum Contributor
    Join Date
    03-04-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    130

    Adding button text change function to existing macro

    Hi All,

    I'm trying to add a command to a macro I found, but being a noob I think I know the command just not how to insert it correctly.

    I have a toggle button which locks and unlocks a workbook and I would like to change the button text when pressed.

    Assuming the following is the correct command to do so.

    Please Login or Register  to view this content.
    But how do I add it to this code?

    Please Login or Register  to view this content.
    Thanks in advance.
    Last edited by JohnDoh; 08-28-2015 at 05:43 AM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Adding button text change function to existing macro

    Good morning JohnDoe

    Remember this is a togglebutton, so just changing the text on the button will do that permanently - after the first time it is clicked it will have no effect thereafter. You need to vary it based on the state of the button which will be true or false. Also, if it is a togglebutton you will need to use .ToggleButton1 and not .Command Button1.

    Something like this would work :
    Please Login or Register  to view this content.
    Incorporated into your code would look something like :

    Please Login or Register  to view this content.
    HTH

    DominicB

  3. #3
    Forum Contributor
    Join Date
    03-04-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    130

    Re: Adding button text change function to existing macro

    Thanks for the reply

    That makes sense, but I get an error @
    Please Login or Register  to view this content.
    This is another noon question, does the fact that I have more than one button make any difference, does each one have a reference?

    Could
    Please Login or Register  to view this content.
    be referring to the wrong button?

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,885

    Re: Adding button text change function to existing macro

    Hi John
    From Developer tab >> click Insert >> draw Toggle Button (ActiveX Control) >> Double click it and in VBE put this code
    Please Login or Register  to view this content.
    From Developer tab >> Click Design mode to exit it ..
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  5. #5
    Forum Contributor
    Join Date
    03-04-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    130

    Re: Adding button text change function to existing macro

    Of course, sorry school boy error.

    Many thanks to you both.

+ 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] adding text to columns to an existing macro
    By sizzi09 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2014, 02:53 PM
  2. Adding in a multiplication function to an existing macro
    By 6423joel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-26-2013, 06:02 PM
  3. Replies: 8
    Last Post: 11-12-2012, 02:39 PM
  4. [SOLVED] Assigning a macro to an existing function button
    By Usethaschwarz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-29-2012, 11:36 AM
  5. Adding a count ticker to a pre-existing button
    By tek0011 in forum Excel General
    Replies: 1
    Last Post: 09-12-2011, 03:50 PM
  6. Replies: 6
    Last Post: 12-23-2009, 02:28 PM
  7. Adding Code to an Existing Command Button with VBA
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2005, 11:36 AM

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