I am trying to add a row on a bottom of my table depending on what checkboxes are checked. COLUMN B successfully pastes the checkbox.caption that has value = true but I want to add text on a specific cell adjacent with the same corresponding row of the checkbox that is checked.
I have this loop to check the true checkboxes:
Code
For j = 0 To Me.Controls.Count - 1
If Left(Me.Controls(j).Name, 8) = "CheckBox" Then
If Me.Controls(j).Value = "True" Then
addRow = 26 + cbCount
newRange = CStr(addRow)
cbCount = cbCount + 1
Range("C" & newRange).Value = text1
End If
End If
Next j
and this code for the checkboxes:
Code
Option Explicit
Dim text1 As String
Sub CheckBox20_Click()
If CheckBox20.Value = True Then
text1 = "aaaaaaaaa"
End If
End Sub
Sub CheckBox21_Click()
If CheckBox21.Value = True Then
text1 = "12121212121"
End If
End Sub
Display More
The problem is that the result ends up like this: the first text with "aaaaaaaaa" gets replaced with "12121212121" of the second checkbox. Basically, the last checked checkbox's text overwrites all text in the column. I have 64 checkboxes.