Referencing VB userforms from Excel cell
Referencing VB userforms from Excel cell
(OP)
Hey guys,
I'm trying to write some simple code that will allow the userform that's opened by a single method to be altered depending on the value in an excel cell.
In the base case, cell A1 in Sheet1 has the value "Userform1". With in the method code I now need to transform this cell reference into a format that is compatible with the "Show" method.
Any help would be welcomed with open arms.
Craig
I'm trying to write some simple code that will allow the userform that's opened by a single method to be altered depending on the value in an excel cell.
In the base case, cell A1 in Sheet1 has the value "Userform1". With in the method code I now need to transform this cell reference into a format that is compatible with the "Show" method.
Any help would be welcomed with open arms.
Craig
RE: Referencing VB userforms from Excel cell
Sub Excelform()
Select Case Cells(1, 1)
Case "userform1"
UserForm1.Show
Case "userform2"
UserForm2.Show
Case "userform3"
UserForm3.Show
End Select
End Sub
RE: Referencing VB userforms from Excel cell
i hope this will solve ur problem
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 And Target.Column = 1 Then
Select Case Target
Case "userform1"
UserForm1.Show
Case "userform2"
UserForm2.Show
Case "userform3"
UserForm3.Show
End Select
Else
UserForm1.Hide
UserForm2.Hide
UserForm3.Hide
End If
End Sub
shakildor
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 1 And Target.Column = 1 Then
Select Case Target
Case "userform1"
UserForm1.Show
Case "userform2"
UserForm2.Show
Case "userform3"
UserForm3.Show
End Select
Else
UserForm1.Hide
UserForm2.Hide
UserForm3.Hide
End If
End Sub