Command Button Rename

imback2nite

Board Regular
Joined
Oct 30, 2004
Messages
203
Office Version
  1. 2003 or older
Platform
  1. Windows
This should be easy but... For some reason I cannot rename Command Button 10. It is in a frame on a Userform. I don't know if that makes a difference. I'm using Windows 10 and Excel 2003. Thank You!!!
VBA Code:
Private Sub CommandButton10_Click()
    ActiveSheet.Unprotect
     If ActiveWindow.FreezePanes = False Then
        ActiveWindow.FreezePanes = True
              Me.CommandButton10.Caption = "Freeze Pane"
    ElseIf ActiveWindow.FreezePanes = True Then
        ActiveWindow.FreezePanes = False
              Me.CommandButton10.Caption = "Unfreeze Pane"
    End If
     Unload UserForm2
     ActiveSheet.Protect
End Sub
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
That code is in the userform module, yes? I would think you'd have to activate the sheet, otherwise the active window is likely the userform where you're clicking the button. Odd though, in that you didn't mention an error so maybe that's not it. BTW, you're not trying to change the button name, you're trying to change its caption, and there is a difference.
 
Upvote 0
That code is in the userform module, yes? I would think you'd have to activate the sheet, otherwise the active window is likely the userform where you're clicking the button. Odd though, in that you didn't mention an error so maybe that's not it. BTW, you're not trying to change the button name, you're trying to change its caption, and there is a difference.

Yes. The code is in the user form module. There is no error message. As a matter of fact, the code works in so far as the panes freeze if unfrozen and unfreezes if frozen. It's just the caption that doesn't change. It's not not monumental if it doesn't but it would be nicer if it did. 🙂
That code is in the userform module, yes? I would think you'd have to activate the sheet, otherwise the active window is likely the userform where you're clicking the button. Odd though, in that you didn't mention an error so maybe that's not it. BTW, you're not trying to change the button name, you're trying to change its caption, and there is a difference.
 
Upvote 0
I tested your code and it works as is for me but I'm on a newer version. The If's seem to be backwards though. One possible solution if you can't get it to work would be to manually set the caption to "Cycle Freeze Pane" as it's kind of obvious as to when the setting is or is not in effect.
 
Upvote 0
I tested your code and it works as is for me but I'm on a newer version. The If's seem to be backwards though. One possible solution if you can't get it to work would be to manually set the caption to "Cycle Freeze Pane" as it's kind of obvious as to when the setting is or is not in effect.
If I select or right-click the button and select Properties, would I be able to leave the caption blank? In the Caption box I have Freeze Pane.
 
Upvote 0
Don't know. You could answer that by testing? In certain cases in Access there is an automatic form caption if the caption option is left blank. I found that entering a single space character in the property sheet for that setting gets rid of the form caption. You could try that too for your button if your idea doesn't work.
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,591
Members
449,174
Latest member
chandan4057

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