PDA

View Full Version : Option Buttons To Command Buttons To Sub Routines



Carpiem
02-15-2006, 02:38 AM
Clicking an option button changes the layout and viewing area of the sheet 1.

Assume that option 1 is selected...... then

a) Command button 1 is clicked calling subroutine 1 to sort part numbers alphanumerically.

b) Command button 2 is clicked calling subroutine 2 to copy a range of cells on sheet 1 and paste into sheet 2.

c) Command button 3 is clicked calling subroutine 3 to copy a range of cells on
sheet 1 and paste into sheet 3.


Now selecting option 2 and repeat the steps above, but call different subroutines (4, 5, 6).


This is what I would like to do. How would I make a command button call a specific subroutine depending on which option button is selected?


I have tried to do this a few ways but nothing worked. Any help or advice would be appreciated.


Thank you,

Carpiem

Dave
02-15-2006, 07:55 AM
Option buttons have a boolean value of true or a numeric value of -1 when selected. So something like this should work. Dave
Private Sub CommandButton1_Click()
If OptionButton1 = -1 Then
Call macro1
End If
If OptionButton2 Then
Call macro4
End If
End Sub

xld
02-15-2006, 08:15 AM
Try something like this


Sub CommandButton1_Click()
If OptionButton1 Then
Subroutine1
Else
Subroutine2
End If
End Sub