0

I trying to get the cancel button in my message box that pops up when I check the box to uncheck the checked box. I've gotten the box to pop up, but my cancel button produces "Run Time error 438".

My current code is as follows:

Sub Checkbox1()

Dim msgRes As VbMsgBoxResult

msgRes = MsgBox("Please review your changes.    If correct, click OK", _
                 vbOKCancel)

If msgRes = vbCancel Then
Sheets("sheet1").Checkbox1.Value = False

End If


End Sub
  • If I remove Sheets("sheet1").Checkbox1.Value = False this line code works fine. What exactly is the problem and at which line? – virusrocks Jun 26 '13 at 09:09
  • I have no vba editor at hand, but could it be, that you have to write `Sheets("Sheet1").Checkbox1.Value = False` ? "sheet1" and "Sheet1" shouldn't be the same. – MiVoth Jun 26 '13 at 09:16

1 Answers1

1

Think your problem is related to this answer

Checking if a worksheet-based checkbox is checked

Give this a try;

If msgRes = vbCancel Then
    Sheets("sheet1").Shapes("Checkbox1").OLEFormat.Object.Value = True
End If
Community
  • 1
  • 1
user692942
  • 16,398
  • 7
  • 76
  • 175
  • 1
    @ChristianF.Pajusi .. you must make a green check below the downvote sign .. since it helped you – matzone Jun 26 '13 at 09:57