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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Buttons

Status
Not open for further replies.

cmoughan

Technical User
Joined
Jul 22, 2003
Messages
9
Location
US
How do you use radio buttons to choose between variables?
ie

button one would choose one certain path to run a macro on a file in a particular folder.

button two would choose a different path to run the SAME macro on a copy of the file in a DIFFERENT folder.

I was asked to do this and I am pretty limited in my skill. Is it a diffcult task?
Thanks
Chris
 
Hi!

This might get you started: Assuming that you have two option buttons on Sheet1 called OptionButton1 and OptionButton2

This code looks to see which one the user has selected. If they haven't chosen either yet, a warning message is popped up, and the macro stops.

Sub GetPath()
Dim myPath As String

myPath = ""
If Sheet1.OptionButton1 Then myPath = "c:\"
If Sheet1.OptionButton2 Then myPath = "D:\"
If myPath = "" Then
MsgBox "Please click one of the option buttons."
Exit Sub
End If
Workbooks.Open myPath & "myfilename.xls"

End Sub

Hope this has helped!

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top