PC Review


Reply
Thread Tools Rate Thread

Check box counting

 
 
jtfalk
Guest
Posts: n/a
 
      20th Oct 2009
Good day,

I have a sheet with multiple check boxes. I would like checkbox1-checkbox5
to sum in cell M10.

For example if checkbox2 and checkbox4 are checked then the value in cell
M10 = 2

Also I am going to be copying this worksheet over and over so it hase to be
worksheet specific.

Any help would be appreciated
 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      20th Oct 2009
do you really need code? If the linked cells are F1:F5 then you could put this

=COUNTIF(F1:F5,"TRUE")

into a cell which would sum the boxes that are checked for you.

"jtfalk" wrote:

> Good day,
>
> I have a sheet with multiple check boxes. I would like checkbox1-checkbox5
> to sum in cell M10.
>
> For example if checkbox2 and checkbox4 are checked then the value in cell
> M10 = 2
>
> Also I am going to be copying this worksheet over and over so it hase to be
> worksheet specific.
>
> Any help would be appreciated

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      20th Oct 2009
--One way is to link the checkbox to each cell and in cell M1 have a formula
to addup these cells..

--If you are looking for a macro...try the below

Sub Macro()
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
For intTemp = 1 To 4
varTemp = varTemp + -(ws.OLEObjects("CheckBox" & intTemp).Object.Value)
Next
Range("M1") = varTemp
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"jtfalk" wrote:

> Good day,
>
> I have a sheet with multiple check boxes. I would like checkbox1-checkbox5
> to sum in cell M10.
>
> For example if checkbox2 and checkbox4 are checked then the value in cell
> M10 = 2
>
> Also I am going to be copying this worksheet over and over so it hase to be
> worksheet specific.
>
> Any help would be appreciated

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      20th Oct 2009
--You can link each checkbox to a cell and then have a formula in cell M1 to
add up the linked cells

--If you are looking for a macro

Sub Macro()
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
For intTemp = 1 To 4
varTemp = varTemp + -(ws.OLEObjects("CheckBox" & intTemp).Object.Value)
Next
Range("M1") = varTemp
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"jtfalk" wrote:

> Good day,
>
> I have a sheet with multiple check boxes. I would like checkbox1-checkbox5
> to sum in cell M10.
>
> For example if checkbox2 and checkbox4 are checked then the value in cell
> M10 = 2
>
> Also I am going to be copying this worksheet over and over so it hase to be
> worksheet specific.
>
> Any help would be appreciated

 
Reply With Quote
 
jtfalk
Guest
Posts: n/a
 
      20th Oct 2009
Okay but how do you reference a checkbox?

Not through the name.
i tried COUNTIF(CheckBox1,TRUE)

"Patrick Molloy" wrote:

> do you really need code? If the linked cells are F1:F5 then you could put this
>
> =COUNTIF(F1:F5,"TRUE")
>
> into a cell which would sum the boxes that are checked for you.
>
> "jtfalk" wrote:
>
> > Good day,
> >
> > I have a sheet with multiple check boxes. I would like checkbox1-checkbox5
> > to sum in cell M10.
> >
> > For example if checkbox2 and checkbox4 are checked then the value in cell
> > M10 = 2
> >
> > Also I am going to be copying this worksheet over and over so it hase to be
> > worksheet specific.
> >
> > Any help would be appreciated

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      20th Oct 2009
This macro will visit each worksheet and put the count you want for that
worksheet in M10 for any worksheets that have CheckBoxes on them...

Sub CountButtons()
Dim CB As OLEObject, WS As Worksheet, Total As Variant, Found As Boolean
For Each WS In Worksheets
Total = 0
Found = False
For Each CB In WS.OLEObjects
If CB.progID Like "*CheckBox*" Then
Found = True
If InStr(1, CB.Name, "checkbox", vbTextCompare) Then
If Right(CB.Name, 1) <= 5 Then
If CB.Object.Value Then Total = Total + 1
End If
End If
End If
Next
If Found Then WS.Range("M10").Value = Total
Next
End Sub

--
Rick (MVP - Excel)


"jtfalk" <(E-Mail Removed)> wrote in message
news:EECE855D-DF29-40BA-BC61-(E-Mail Removed)...
> Good day,
>
> I have a sheet with multiple check boxes. I would like checkbox1-checkbox5
> to sum in cell M10.
>
> For example if checkbox2 and checkbox4 are checked then the value in cell
> M10 = 2
>
> Also I am going to be copying this worksheet over and over so it hase to
> be
> worksheet specific.
>
> Any help would be appreciated


 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      20th Oct 2009
Put this code in the sheet code module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For i = 1 To 5
If Me.OLEObjects("CheckBox" & i).Object = "True" Then
x = x + 1
End If
Next
Range("M10") = x
End Sub


When you copy the sheet the code goes with it.


"jtfalk" <(E-Mail Removed)> wrote in message
news:EECE855D-DF29-40BA-BC61-(E-Mail Removed)...
> Good day,
>
> I have a sheet with multiple check boxes. I would like checkbox1-checkbox5
> to sum in cell M10.
>
> For example if checkbox2 and checkbox4 are checked then the value in cell
> M10 = 2
>
> Also I am going to be copying this worksheet over and over so it hase to
> be
> worksheet specific.
>
> Any help would be appreciated



 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      20th Oct 2009
In design mode right click each checkbox and from the properties window set
the linked cell to a cell F1....Do the same for all cells and then apply this
formula in M1

If this post helps click Yes
---------------
Jacob Skaria


"jtfalk" wrote:

> Okay but how do you reference a checkbox?
>
> Not through the name.
> i tried COUNTIF(CheckBox1,TRUE)
>
> "Patrick Molloy" wrote:
>
> > do you really need code? If the linked cells are F1:F5 then you could put this
> >
> > =COUNTIF(F1:F5,"TRUE")
> >
> > into a cell which would sum the boxes that are checked for you.
> >
> > "jtfalk" wrote:
> >
> > > Good day,
> > >
> > > I have a sheet with multiple check boxes. I would like checkbox1-checkbox5
> > > to sum in cell M10.
> > >
> > > For example if checkbox2 and checkbox4 are checked then the value in cell
> > > M10 = 2
> > >
> > > Also I am going to be copying this worksheet over and over so it hase to be
> > > worksheet specific.
> > >
> > > Any help would be appreciated

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting check boxes =?Utf-8?B?RGVhbg==?= Microsoft Access Reports 3 8th Aug 2007 05:26 PM
Counting Check Boxes =?Utf-8?B?TmljayBDV1Q=?= Microsoft Access Reports 4 31st May 2007 09:38 PM
Counting of Check boxes =?Utf-8?B?a3RmcnViZWw=?= Microsoft Access 8 26th Oct 2006 03:41 AM
Counting Check Boxes =?Utf-8?B?Qm96?= Microsoft Access Queries 1 29th Jun 2006 03:11 PM
Counting Check Boxes =?Utf-8?B?RUI=?= Microsoft Access Reports 2 26th Dec 2003 06:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:43 PM.