Share via

Trigger macro when clicking on a checkbox changes value of linked cell of the checkbox

Anonymous
2017-10-31T09:43:29+00:00

Hi All,

I have a checkbox with a linked cell A1. I want to run a macro when clicking on the checkbox changes value of A1 from TRUE to FALSE or FALSE to TRUE.

I tried Worksheet_calculate and Workbook_SheetCalculate events but they are not triggered.

Thanks,

Stefi

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

Answer accepted by question author

OssieMac 48,001 Reputation points Volunteer Moderator
2017-10-31T11:12:44+00:00

Why not just attach code to the checkbox instead of the worksheet?

However, to force the calculate to run you could insert a formula in another cell that will trigger the calculate event when A1 changes value. Just insert the formula =A1 in any other cell (even one out of the way of your main data) and then when A1 changes, the formula will trigger the calculate event.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2017-11-01T14:40:09+00:00

    Hi OssieMac,

    I was forced to attach the code to Workbook_SheetCalculate because the sheets containing the checkboxes were created dynamically and I didn't know a way to add a code snippet to a sheet code by means of a VBA program.

    Nevertheless your suggestion works very well, thank you!

    Regards,

    Stefi

    Was this answer helpful?

    0 comments No comments