ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Check for "CheckBox" (https://www.excelbanter.com/excel-discussion-misc-queries/185490-check-checkbox.html)

ekreider

Check for "CheckBox"
 
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

Dave Peterson

Check for "CheckBox"
 
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

ekreider wrote:

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


--

Dave Peterson

ekreider

Check for "CheckBox"
 
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

"Dave Peterson" wrote:

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

ekreider wrote:

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


--

Dave Peterson



All times are GMT +1. The time now is 02:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com