question regaridng checkboxes

M

Monte0682

I have 10 checkboxes on my worksheet. I wrote this code:

Public Function Check_box(i)
If Sheet1.CheckBox1.Value = True Then
Range("B3:G3").Interior.Color = RGB(135, 206, 235)
Range("G3").Value = "YES"
Range("G3").HorizontalAlignment = xlCenter
Else
Range("B3:G3").Interior.ColorIndex = xlNone
Range("G3").Value = ""
End If

End Function

How can I modify this so I can use it for all checkboxes... I know on
the forms you can use something:

controls("Checkbox"&i).value...etc where i is the checkbox number
 
K

kemal

I put just for 3 of them.You can put 10 of course.


If Me.CheckBox1 Or Me.CheckBox2 Or Me.CheckBox3 Then
Range("B3:G3").Interior.Color = RGB(135, 206, 235)
Range("G3").Value = "YES"
Range("G3").HorizontalAlignment = xlCenter
Else
Range("B3:G3").Interior.ColorIndex = xlNone
Range("G3").Value = ""
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top