Reputation: 531
On my spreadsheet, cell E8 will contain the name of a UserForm. For this example "mainMenu".
On my UserForm "newClient", when the button "btnAddClient" is clicked, I'd like to unload the "newClient" form and show whichever form matches the name that is shown in cell E8.
I've tried the following different code but none work. How can this be done?
ActiveSheet.Range("E8").Text.Show
ActiveSheet.Range("E8").Value.Show
ActiveSheet.Range("E8").Show
Upvotes: 0
Views: 199
Reputation: 7941
I assume that you will know upfront which user forms are in your excel spreadsheet. Try something like this
Sub Test()
Dim formName As String
formName = Worksheets("Sheet1").Range("E8").Value
Select Case formName
Case "UserForm1"
UserForm1.Show
Case "UserForm2"
UserForm2.Show
End Select
End Sub
Upvotes: 1