+ Reply to Thread
Results 1 to 4 of 4

Change Button name when clicked

  1. #1
    Registered User
    Join Date
    03-01-2012
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2010
    Posts
    64

    Change Button name when clicked

    Hello people

    This might be a simple one but I'm a bit stumped and pressed for time too, so if anyone can help that would be appreciated!

    I have a simle macro that hides and unhides a section of a worksheet:

    Sub Button4_Click()

    Columns("G:H").EntireColumn.Hidden = Not Columns("G:H").EntireColumn.Hidden
    End Sub

    How would I expand this such that when the button is clicked to hide the columns the button name changes to "Show Columns", and when it is clicked again to show the columns it changes the name to "Hide Columns"?

    Thanks in advance
    Kenny

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Change Button name when clicked

    as an option,
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Change Button name when clicked

    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    03-01-2012
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Change Button name when clicked

    Thanks to you both for the prompt reply, both methods are spot on what I need

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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