Search code examples
excelvbaconditional-formatting

Conditional formatting and automatically assign it to the cell value on the right


This is for a calendar that displays a strikethrough once a box is checked.

My conditional formatting for cells B6:B11 formats the value to C6 to display the strikethrough once the box is checked.

Is there an easier way to go about this instead of manually adding the conditional formatting to every date of the month?

Is there a way to have it done automatically like the checkbox was done?

Sub AssignCell()

Dim cbox As CheckBox

For Each cbox In ActiveSheet.CheckBoxes
     cbox.LinkedCell = cbox.TopLeftCell.Address
Next cbox

End Sub

enter image description here


Solution

  • You don't have to separately add conditional formatting for each day. Instead you can do it with one conditional format. Apply the conditional format to the entire calendar starting from B5, and use the formula =AND(ISTEXT(B5), C5)