Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Displaying different worksheets based on user input

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Displaying different worksheets based on user input

David,

Declare the variable

Public sscreen As String

Select General|Declarations
and paste it in there.

Mike

"David" wrote:

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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Displaying different worksheets based on user input

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.

David wrote:
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!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Displaying different worksheets based on user input

Thanks both, now working!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying a result based on user selection Emma Excel Discussion (Misc queries) 3 June 9th 09 08:08 PM
displaying input data on user form as currency mantrid Excel Programming 2 April 28th 07 01:56 AM
Autofilter based on user input? Randy Excel Programming 0 February 28th 07 10:52 PM
Displaying cell contents based on input? Fleone Excel Programming 7 February 2nd 05 12:09 AM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 12:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"