View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default How to count the number of selected combobox within Excel?

I think he just wants to count the ones 'selected/checked' - and I have to
run off to the office right now. Needs one more test inside the If..End If ??

"Jacob Skaria" wrote:

Hi Eric

If you have only combo boxes in your sheet try the below line of code in
VBE. If you are new to VBE press Alt+F11 from workbook to launch VBE. From
menu ViewImmediate Window. Activate the sheet with the controls and in
immediate window type which will return the number of controls

?ActiveSheet.OLEObjects.count

If you have other controls try the below macro. To run a macro set the
Security level to low/medium in (Tools|Macro|Security). From workbook launch
VBE using short-key Alt+F11. From menu 'Insert' a module and paste the below
code. Save. Get back to Workbook. Run macro from Tools|Macro|Run <selected
macro()

Reference Microsoft Forms 2.0 Object Library from VBEToolsReferences

Sub CountCombo()
Dim intTemp
For Each objtemp In ActiveSheet.OLEObjects
If TypeOf objtemp.Object Is MSForms.ComboBox Then
intCount = intCount + 1
End If
Next
MsgBox "Number of Combo boxes :" & intCount
End Sub




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


"Eric" wrote:

Does anyone have any suggestions on how to count the number of combobox
within Excel?
I have created a few square click box under form tool, and I would like to
count how many numbers of box has been selected, does anyone have any
suggestions on how to do it?
Thanks in advance for any suggestions
Eric