Share via

Option button issues

Anonymous
2011-03-02T18:41:01+00:00

I have a UserForm that has three option buttons on it.  The names of the labels are easy, medium, hard.  I have a button on one of my sheets that launches a different UserForm.  Now when the first UserForm medium button is checked I get a run-time error '13' type mismatch error.  If any of the other two buttons are checked I don't get any errors and everything works fine.  I'm not sure what code I would need to post here.

[code]Private Sub CommandButton1_Click()

If easy.Value = True Then

Sheets("DATA").Range("H14").Value = 1

ElseIf medium.Value = True Then

Sheets("DATA").Range("H14").Value = 2

Else

Sheets("DATA").Range("H14").Value = 3

End If[/code]

On that same option button user form there is a "DONE" button.  When clicked it runs the code stated above.  I'm sure you guys will need more info, but I don't know what to put on here.  I guess I just want to get your initial thoughts and go from there.

Thanks

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2011-03-03T12:18:36+00:00

    Yes, the code works if the easy or hard option button is selected, only when medium is selected is when it doesn't.  The only code that is linked to the buttons is that if the easy button is selected it puts a "1" in a cell, if medium is selected it puts a "2", and if hard is selected it puts a "3".  This all happens when I click the "DONE" button on that same UserForm.  But if you double click on an option button to bring up the code, there isn't any code written for the buttons.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-03-03T09:51:32+00:00

    fride360,

    Which code is linked to the 'medium' button?

    Does the code 'continue to work' all the way through after loading your Check_In form?

    ___________________

    Regards, Tom

    Was this answer helpful?

    0 comments No comments
  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. Anonymous
    2011-03-02T20:41:33+00:00

    When the error pops up the code steps in here:

    Sub CheckIn()

    Load Check_In (THIS LINE)

    Check_In.Show

    End Sub

    but usually if there's an error you can't continue stepping through the code.  In this situation I can and it continues to work.  It's only if I click the button on the spreadsheet.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2011-03-02T20:22:44+00:00

    Just a guess.

    I'm guessing that the line that causes the error is:

    Sheets("DATA").Range("H14").Value = 1

    If that's true, then you may have an error in H14 of the Data worksheet.  Using the .value property will cause an error.

    You can add a check:

    if iserror(worksheets("data").range("H14").value) then

      'what should happen

    else

      if worksheets("data").range("H14").value = 1 then

        ...

    ps.  If this doesn't help, you should give more info -- what's in the cell and what line causes the trouble.

    Was this answer helpful?

    0 comments No comments