Results 1 to 5 of 5

Adding button text change function to existing macro

Threaded View

  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.

    commandbutton1.caption = "xxxxxxxxx"
    But how do I add it to this code?

    Sub ToggleProtect()
    
    Const PW As String = "test"
    
    With Sheets(ActiveSheet.Name)
    
    If .ProtectContents = False Then
    .Protect PW
    
    Else
    .Unprotect PW
    
    End If
    End With
    
    End Sub
    Thanks in advance.
    Last edited by JohnDoh; 08-28-2015 at 05:43 AM.

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