Evan West
Evan West

Reputation: 53

Getting Check Boxes to "Check" with VBA Conditionally

I am trying to get the a box in golden column of check boxes, that you can see on the Left, to check if a date in the corresponding column is present under Original plan and a box in the white column of check boxes to check if a date is present in the corresponding column under Updated Estimate.

Very new at this and I've been playing around with it for a while and can't get it to work right.

Here is the sheet i am talking about:
Here is the sheet i am talking about

Upvotes: 1

Views: 67

Answers (1)

K.Dᴀᴠɪs
K.Dᴀᴠɪs

Reputation: 10139

These resemble ActiveX checkboxes, so that's what this answer is going to apply to. If this isn't the case, then hopefully this will still help someone else 5 years from now.

Anyway, Let's say you named the checkbox cb_A1 for left checkbox and cb_B1 for the right. You can change the value of these checkboxes by appending the Sheet's Codename before the checkbox name. Example:

Sheet1.cb_A1.Value = True
' ^^^   ^^^
'  |     ↳ Name of Checkbox
'  ↳ Sheet's Codename

Since your image didn't include the column headers, let's assume Orginal Date's column was E. You can perform your check in this column as such:

If IsDate(Sheet1.Range("E1")) And Sheet1.Range("E1").Value > 0 Then 
    Sheet1.cb_A1.Value = True
Else
    Sheet1.cb_A1.Value = False
End If

Upvotes: 1

Related Questions