PDA

View Full Version : when the checkbox is checked, something must only happen in that row



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

p45cal
04-02-2023, 10:21 AM
Attach a workbook please. If it contains sensitive data, remove everything except things relating to this problem, make sure you still get the error, and attach that instead.
It will answer many questions such as the kind of check box, where you've put the code and more. It will also mean you get a better chance of a solution that will work for you.

arnelgp
04-02-2023, 05:56 PM
you should change your Checkbox to Form Control Checkbox (not ActiveX)

Aussiebear
04-05-2023, 04:23 AM
Due to lack of interest in this thread by RuneDefour, I am going to close it.