RuneDefour
04-02-2023, 08:27 AM
when the checkbox is checked, something must only happen in that row. namely column 5 and column 7 are added and the result is in column 5 . and it changes color to white. but this must be just before the row containing the checkbox. how to do this i tried this now ma get an error and don't know why. the bold is the error
Private Sub CheckBox1_Click()
Dim cb As CheckBox
Dim i As Integer
Set cb = ActiveSheet.CheckBoxes(Application.Caller)
If cb.Value = True Then
i = cb.TopLeftCell.Row
If Not IsEmpty(Cells(i, 7)) And Not IsEmpty(Cells(i, 5)) Then
Cells(i, 5).Value = Cells(i, 5).Value + Cells(i, 7).Value
Cells(i, 5).Interior.ColorIndex = xlColorIndexNone
Cells(i, 7).Value = 0
End If
End If
End Sub
Private Sub CheckBox1_Click()
Dim cb As CheckBox
Dim i As Integer
Set cb = ActiveSheet.CheckBoxes(Application.Caller)
If cb.Value = True Then
i = cb.TopLeftCell.Row
If Not IsEmpty(Cells(i, 7)) And Not IsEmpty(Cells(i, 5)) Then
Cells(i, 5).Value = Cells(i, 5).Value + Cells(i, 7).Value
Cells(i, 5).Interior.ColorIndex = xlColorIndexNone
Cells(i, 7).Value = 0
End If
End If
End Sub