#1   Report Post  
Posted to microsoft.public.excel.misc
Jo Jo is offline
external usenet poster
 
Posts: 113
Default Forms Checkbox

I have a list of names with checkboxes next to them. I want to add up all
the checkboxes that are ticked. Approx 100 lines.

I have not linked them already to a cell and don't want to change the code
for every cell individually.

Is there a quick way to do this?

Thanks very much
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Forms Checkbox

You could use a macro to add the linked cell.

This code assumes that you used the checkbox from the Forms toolbar--not from
the Control Toolbox toolbar and it links the cell directly below the
checkbox--and hides the value in that cell using a custom format:

Option Explicit
Sub testme()
Dim CBX As CheckBox
With Worksheets("sheet1")
For Each CBX In .CheckBoxes
With CBX
.LinkedCell = .TopLeftCell.Address(external:=True)
.TopLeftCell.NumberFormat = ";;;"
End With
Next CBX
End With
End Sub

Then you could use:
=countif(yourrange,true)
to count the number checked.

=======

This code assumes you used the checkbox from the Control toolbox toolbar--not
the Forms toolbar:

Option Explicit
Sub testme2()
Dim OLEObj As OLEObject
With Worksheets("sheet1")
For Each OLEObj In .OLEObjects
With OLEObj
If TypeOf .Object Is msforms.CheckBox Then
.LinkedCell = .TopLeftCell.Address(external:=True)
.TopLeftCell.NumberFormat = ";;;"
End If
End With
Next OLEObj
End With
End Sub

And the same formula could be used.
=countif(yourrange,true)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
Jo wrote:

I have a list of names with checkboxes next to them. I want to add up all
the checkboxes that are ticked. Approx 100 lines.

I have not linked them already to a cell and don't want to change the code
for every cell individually.

Is there a quick way to do this?

Thanks very much


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jo Jo is offline
external usenet poster
 
Posts: 113
Default Forms Checkbox

Thanks very much Dave...worked a treat.

"Dave Peterson" wrote:

You could use a macro to add the linked cell.

This code assumes that you used the checkbox from the Forms toolbar--not from
the Control Toolbox toolbar and it links the cell directly below the
checkbox--and hides the value in that cell using a custom format:

Option Explicit
Sub testme()
Dim CBX As CheckBox
With Worksheets("sheet1")
For Each CBX In .CheckBoxes
With CBX
.LinkedCell = .TopLeftCell.Address(external:=True)
.TopLeftCell.NumberFormat = ";;;"
End With
Next CBX
End With
End Sub

Then you could use:
=countif(yourrange,true)
to count the number checked.

=======

This code assumes you used the checkbox from the Control toolbox toolbar--not
the Forms toolbar:

Option Explicit
Sub testme2()
Dim OLEObj As OLEObject
With Worksheets("sheet1")
For Each OLEObj In .OLEObjects
With OLEObj
If TypeOf .Object Is msforms.CheckBox Then
.LinkedCell = .TopLeftCell.Address(external:=True)
.TopLeftCell.NumberFormat = ";;;"
End If
End With
Next OLEObj
End With
End Sub

And the same formula could be used.
=countif(yourrange,true)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
Jo wrote:

I have a list of names with checkboxes next to them. I want to add up all
the checkboxes that are ticked. Approx 100 lines.

I have not linked them already to a cell and don't want to change the code
for every cell individually.

Is there a quick way to do this?

Thanks very much


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
checkBox help!!! riggi Excel Discussion (Misc queries) 1 December 6th 06 09:31 PM
Click event for checkbox from Forms toolbar Carolyn Excel Discussion (Misc queries) 6 September 11th 06 08:16 PM
How do I resize the actual Forms checkbox Nel Excel Discussion (Misc queries) 1 March 22nd 06 09:23 PM
EXCEL FORMS CHECKBOX BLUOVAL Excel Worksheet Functions 3 October 17th 05 06:40 PM
checkbox Chas Excel Worksheet Functions 2 May 13th 05 10:37 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"