Thread
:
Customizing userforms on button clicks
View Single Post
#
4
Posted to microsoft.public.excel.programming
Ken Puls
external usenet poster
Posts: 58
Customizing userforms on button clicks
Well, here's one way.
Private Sub CommandButton1_Click()
Call ChangeCaption("CommandButton1")
End Sub
Private Sub ChangeCaption(sCaptionName As String)
Select Case sCaptionName
Case Is = "CommandButton1"
Me.Caption = "MyCustomTitle"
Case Else
Me.Caption = "Something else"
End Select
End Sub
The only benefit that I can see to doing this, though, is to have a
place to centrally manage the naming. It's actually more code than just
changing it in the Button_Click event.
Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca
wrote:
yes - the buttons are in the userform
On Oct 30, 4:32 pm, Ken Puls wrote:
Hi there,
These are buttons inside the userform? The long way to do it would be
calling a function to evaluate what button was clicked. It's a simple
one liner to change the caption in your Button_Click event:
Me.Caption = "MyCustomTitle"
HTH,
Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca
wrote:
I have a series of buttons all using the same Userform. However, I
would like to be able to personalize the title of the userform -
depending on what button is clicked.
The long way to do it, would be to have a short macro for each button,
that would each generate the userform and accordingly change the
caption details.
But I am assuming there should be a shorter way, to enable a large set
of buttons to use the same userform and be able to personalize the
title as required. Perhaps a series of case statements or even somthing
simpler??
Reply With Quote
Ken Puls
View Public Profile
Find all posts by Ken Puls