Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping the value of a variable outside of the subroutine

Status
Not open for further replies.

rendezvous

IS-IT--Management
Feb 27, 2003
5
CA
In Excel, I have a selection of 4 radio buttons. When I click one of the 4 buttons, I am trying to find and store a value that the radio button has been selected, but once the subroutine has ended the value of the variables is reset. How can I keep the value of the variable, is there a better way.

thanks

*********
Public level1 As Integer

Sub OptionButton61_Click()
level = 1
End Sub

Sub OptionButton62_Click()
Value = True
level = 2
End Sub

same code for the next 2 radio buttons
*********

 
Set a value on a sheet in the click event
Range("A1").Value = OptionButton62.Value Skip,
Skip@theofficeexperts.com
 
If you don't need to keep the value when the workbook is closed, then you can use a public variable. Make sure you declare the variable in a regular module (not an object code module). I noticed you declare your variable with name "level1", but in the subs it is "level". Just a typo, or part of the problem?
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top