Click an Optionbutton

J

jnf40

I have a workbook, wb1, that when a different date is entered in a cell then
a new workbook, wb2, is opened with everything the same as the previous
workbook. There are 7 optionbuttons, group 1 contains optionbuttons 1 and 2,
group 2 contains optionbuttons 3 and 4 and group 3 contains optionbuttons 5,
6, and 7. When wb2 opens I want the values of the optiobuttons in wb1 to be
transfered to the optionbuttons in wb2. The optionbuttons are linked to cells
by code.
 
J

jnf40

I was looking for the easiest way to have wb2 optionbuttons either clicked or
not clicked based on wb1 optionbuttons value. The linked cell as described
earlier would also have to relate the same value as wb1.
 
S

stevebriz

Are the option button values copied as cells values to workbook 2?
If they are thenput in the form_initialize of WB2 put in :
optionbutton1. value = Wb2.sheet(1).cells( i,j).value

not 100% if this is what you are looking for...but if is not
...explain to a little more for us.
 
J

jnf40

There are 7 optionbuttons, created from the forms tool bar on the worksheet,
group 1 contains optionbuttons 1 and 2, if opb1 is clicked then cell F1 would
= 1 if opb2 is clicked then F1 would = 2. Group 2 contains optionbuttons 3
and 4, if opb3 is clicked then cell F2 would = 1 if opb4 is clicked then F2
would = 2. Group 3 contains optionbuttons 5, 6, and 7, if opb5 is clicked
then cell F3 would = 1 if opb6 is clicked then F3 would = 2, and if opb7 is
clicked then F3 would = 3. When wb2 opens I want the values of the
optiobuttons in wb1 to be transfered to the optionbuttons in wb2. The
optionbuttons are linked to cells by code in module1 as follows.

Sub OptionButton1_Click()
ActiveSheet.Unprotect Password:="ABC"
Range("F1") = 1
ActiveSheet.Protect Password:="ABC", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True
End Sub

Sub OptionButton2_Click()
ActiveSheet.Unprotect Password:="ABC"
Range("F1") = 2
ActiveSheet.Protect Password:="ABC", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True
End Sub

and so on for the remainder of the optionbuttons. The optionbuttons are on
the worksheet not on a form.
I guess I need to know, will it be easier to check the cell values of F1,
F2, and F3 and have

wb2!F1 = wb1!F1

and so on then check the value of each optionbutton like,

If wb1.Shapes("Option Button 1").Value = xlOff Then
wb2.Shapes("Option Button 1").Value = xlOff
Else Shapes("Option Button 1").Value = xlOn
End If
If wb1.Shapes("Option Button 2").Value = xlOff Then
wb2.Shapes("Option Button 2").Value = xlOff
Else Shapes("Option Button 2").Value = xlOn
End If

if that's the proper way to reference the optionbuttons. I hope I haven't
made it more confusing.
 
S

stevebriz

I think its easier to reference the cells
then the button just reflect the cell values each time you open the WB
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