Displaying different worksheets based on user input

D

David

I've the following code in a User Form:

------

Private Sub OptionButton1_Click()
sScreen = "Purchase"
End Sub

Private Sub OptionButton2_Click()
sScreen = "Remortgage"
End Sub

Private Sub CommandButton2_Click()
'' They've clicked proceed, which screen do we open next?
If (sScreen = "Remortgage") Then
Sheets("Sheet2").Activate
Else
Sheets("Sheet3").Activate
End If
Unload UserForm1
End Sub

----

It always displays "Sheet3" after the "proceed" button is pressed,
regardless of which radio button the user selects, I assume the
variable sScreen isn't being carried over into the final Private Sub,
what do I need to do to ensure it is?

Or is there another problem here?

Excel 97.
Thanks for any help!
 
G

Guest

David,

Declare the variable

Public sscreen As String

Select General|Declarations
and paste it in there.

Mike
 
J

JW

You are sharing variables across the userform, so you to declare the
variable as a Public Variable. At the top of your userform subs,
place:
Public sScreen As String

That should fix ya up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top