View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.newusers
KneeDown2Up KneeDown2Up is offline
external usenet poster
 
Posts: 17
Default simplifying routine

I have the following procedure for a checkbox. The trouble is it feels very
cumbersome and long and I have to do it for each box; is there a shorter more
efficient way to do the same?

Private Sub CheckBox87_Click()
cellno = "f34"
If CheckBox87.Value = True Then
Me.Cells.Range(cellno).Font.Color = RGB(0, 255, 0)
Me.Cells.Range(cellno).Font.Bold = True
CheckBox88.Visible = False
Else: Me.Cells.Range(cellno).Font.Color = RGB(0, 0, 255)
Me.Cells.Range(cellno).Font.Bold = False
CheckBox88.Visible = True
End If

Because I need a large number of these boxes, I was thinking of a routine
such as;

For i = 1 to 200

If CheckBox(i).Value = True Then
Me.Cells.Range(cellno).Font.Color = RGB(0, 255, 0)
Me.Cells.Range(cellno).Font.Bold = True
CheckBox(i+1).Visible = False
Else: Me.Cells.Range(cellno).Font.Color = RGB(0, 0, 255)
Me.Cells.Range(cellno).Font.Bold = False
CheckBox(i+1).Visible = True
End If
next i

which would be a load easier than having to copy this the required number of
times for each checkbox. Can anybody guide me in the right direction please?

Many thanks in advance.