×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

OptionButton selections in excel

OptionButton selections in excel

OptionButton selections in excel

(OP)
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

RE: OptionButton selections in excel

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

RE: OptionButton selections in excel

(OP)
Thanks it worked! I really appreciate you’re help

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources