Defining UserForm Caption from a Variable
In the example nbelow the userform is opened using the workbook open event
and the userform is called with whatever caption is type in cel 1,1 of sheet
1.
Private Sub Workbook_Open()
UserForm1.Caption = Worksheets("Sheet1").Cells(1, 1).Text
UserForm1.Show
End Sub
Mike
" wrote:
Hello all mighty Excel gurus!
I was wondering if it's possible to pass a variable in when showing a
userform to set the caption. I have made UserForm1 and based on a
variable set earlier in the macro I want to be able to assign a
"caption". Obviously I can set it in the Properties by clicking the
Caption setting and typing anything I want. But can I do something
like this (and pardon the "fantasy" code):
Dim FormName as String
FormName = Range("A1").Value
UserForm.show Caption:=FormName
Is something like that possible? Can I send in a predefined variable
to set the caption on the fly when it opens (shows) the UserForm?
Thanks!
Steve
|