Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

OptionButton selections in excel

Status
Not open for further replies.

MarkusLAndersson

Mechanical
Aug 11, 2005
20
Hi

I am having trouble using OptionsButtons in a UserForm. I wand the user to make a choos between three types of options. If he clicks OptionsButton1 row 23 & 24 is to be hidden from the user in worksheet 1( in excel). If OptionsButton2 or OptionsButton3 is clicked the rows should be shown. Also the value in cell E20 and E21 is to change. My code (as you can se below) makes the change in E20 and E21 but do not hid or show row 23 & 24. Can some one help me whit how to write the code sow it works.

Thank in advance Markus
__________________________________________________________
Private Sub CommandButton1_Click()

If OptionButton1.Caption = "OK" Then
Sheets("sheet1").Cells(20, 5).Value = "I-suport"
Sheets("sheet1").Range("A23:F24").Select
Sheets("sheet1").Range("F24").Activate
Sheets("sheet1").Selection.EntireRow.Hidden = True
Sheets("sheet1").Range("A25").Select
Sheets("sheet1").ActiveCell.FormulaR1C1 = "12"
Sheets("sheet1").Range("B22").Select

End If

If OptionButton2.Caption = "OK" Then
Sheets("sheet1").Range("A22:F25").Select
Sheets("sheet1").Selection.EntireRow.Hidden = False
Sheets("sheet1").Range("A25").Select
Sheets("sheet1").ActiveCell.FormulaR1C1 = "14"
Sheets("sheet1").Range("H21").Select
End If

If OptionButton3.Caption = "OK" Then
Sheets("sheet1").Range("A22:F25").Select
Sheets("sheet1").Selection.EntireRow.Hidden = False
Sheets("sheet1").Range("A25").Select
Sheets("sheet1").ActiveCell.FormulaR1C1 = "14"
Sheets("sheet1").Range("H21").Select
End If

Unload Typeofsuport
End Sub
__________________________________________________________
Private Sub CommandButton2_Click()
Unload Typeofsuport
End Sub
__________________________________________________________
Private Sub OptionButton1_Click()
Sheets("sheet1").Cells(20, 5).Value = "I-suport"
Sheets("sheet1").Cells(20, 6).Value = "I-suport"
End Sub
__________________________________________________________
Private Sub OptionButton2_Click()
Sheets("sheet1").Cells(20, 5).Value = "T-suport"
Sheets("sheet1").Cells(20, 6).Value = "T-suport"
End Sub
__________________________________________________________
Private Sub OptionButton3_Click()
Sheets("sheet1").Cells(20, 5).Value = "pi-suport"
Sheets("sheet1").Cells(20, 6).Value = "pi-suport"
End Sub
 
Replies continue below

Recommended for you

Hi Markus,

How about:

Code:
If OptionButton1.Caption = "OK" Then
  Sheets("sheet1").Cells(20, 5).Value = "I-suport"
  Sheets("sheet1").Rows(23).Hidden = True
  Sheets("sheet1").Rows(24).Hidden = True
  ...
End If

HTH
Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor