Check for "CheckBox"

E

ekreider

I have a Uerform that has "CheckBoxes" and I would like to check and see
which is true so I can enter some data into a cell. The check boxes are
listed as SunCheckbox, MonCheckBox, and so on. The example I am sending is
just a simple example and the letter "n" is to repersent the check box name.

Example:
For c = 1 to 7
n = Format(c, "ddd") & "CheckBox"
If n = True Then Activecell.Offset(0, c+1) = 1
Next c

I hope you can understand what I am trying to do.

Thanks,

ek
 
D

Dave Peterson

Option Explicit
Private Sub CommandButton1_Click()
Dim CBXCtr As Long
Dim CBXName As String
For CBXCtr = 1 To 7
CBXName = Format(CBXCtr, "ddd") & "CheckBox"

If Me.Controls(CBXName).Value = True Then
ActiveCell.Offset(0, CBXCtr + 1).Value = 1
Else
'shouldn't you have this, too?
'ActiveCell.Offset(0, CBXCtr + 1).Value = 0
End If
Next CBXCtr
End Sub
 
E

ekreider

Dave,

Thanks for the help I knew it was simple but I just couldn't get the right
combonation. There is more to the code then what I wrote I just needed to
check to see if the check box was true.

Thank you verry much,

ek
 

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