checkboxes

  • Thread starter Thread starter RICHARD
  • Start date Start date
R

RICHARD

Hi,

I have an excel sheet with multiple checkboxes located in
each row (180 checkboxes in column C) and would like to
have the user click on any checkboxes regardless of the
row and have the row's cell A, where that checkbox is
located to change color to yellow. While i have done it
with each checkbox programed by itself:






Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Sheet1.Cells(2, 1).Interior.Color = vbYellow
Sheet1.Cells(2, 7).Value = "Done!"
End If
If CheckBox1 = False Then
Sheet1.Cells(2, 1).Interior.Color = vbWhite
Sheet1.Cells(2, 7).Value = ""
End If
End Sub
and on, and on......I ran into a problem. I had to sort
sheet1 and now, it when I click on the any CheckBoxes,
none works. I would like to write a loop that does what
each checkbox does without having to write the same
program 180 times. However, I don't know how to do that.
What I tried to do does not work:

Here is a sample of what I tried to do:

Public Sub click_on()
Dim iRow As Integer
For iRow = 1 To 180
If CheckBox(iRow) = True Then
Cells(iRow, 7).Interior.Color = vbGreen
Else
Cells(iRow, 7).Interior.Color = vbBlue
End If

Next iRow
End Sub
Can somebody help me???
 
Back
Top