I have a cell (B18) for users to input a number between 0 and 5
I have an adjacent cell (C18) which is a check box.
The combination of these two cells outputs a number to a different cell. I'm trying to write a code in VBA which automatically checks the check box in C18, every time the value of the B18 is 5.
I have managed to accomplish this with:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("B18").Address Then
Range("C18").Formula = "=IF(B18=5,TRUE,FALSE)"
End If
End Sub
This seemed to work at first. Every time I would change cell B18 to 5, then C18 would be "TRUE". Every time I changed B18 to 4, C18 would read "FASLE". The problem comes when I manually check the box. There are situations where B18 can be less than 5 and the checkbox in C18 still needs to be checked. Once I do this however, the formula no longer works and C18 wont read TRUE is B18 is set to 5.
I hope I explained this clearly. I would appreciate any help.
I have an adjacent cell (C18) which is a check box.
The combination of these two cells outputs a number to a different cell. I'm trying to write a code in VBA which automatically checks the check box in C18, every time the value of the B18 is 5.
I have managed to accomplish this with:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("B18").Address Then
Range("C18").Formula = "=IF(B18=5,TRUE,FALSE)"
End If
End Sub
This seemed to work at first. Every time I would change cell B18 to 5, then C18 would be "TRUE". Every time I changed B18 to 4, C18 would read "FASLE". The problem comes when I manually check the box. There are situations where B18 can be less than 5 and the checkbox in C18 still needs to be checked. Once I do this however, the formula no longer works and C18 wont read TRUE is B18 is set to 5.
I hope I explained this clearly. I would appreciate any help.