Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to select cells with checkboxes?


Hi
I have two columns in a sheet one with values and one with check box
activex control

value1 checkbox1
value2 checkbox2
value3 checkbox3
:

I would like to collect all values for which the checkbox is checked
I can get the selected checkboxes but how do i refer to the values
column?

Thanks in advance.

Function GetSelectedCheckBoxes(toIndex As Integer)

Const cbName As String = "cbSelectOption"
Const fromIndex As Integer = 1

Dim Index As Integer
Dim Selected As New Collection
Dim cb
Dim controlName As String

For Index = fromIndex To toIndex
Dim theWorkSheet As Worksheet
Set theWorkSheet = ThisWorkbook.ActiveSheet
controlName = cbName & Index
Set cb = theWorkSheet.OLEObjects(controlName).Object
If (cb.Value = True) Then
Selected.Add cb
End If
Next Index
Set GetSelectedCheckBoxes = Selected

End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default How to select cells with checkboxes?

Take a look at the modifications I made below.
It finds the row based on the top left corner of the checkbox and
assumes where the values are stored is column 1.

On Apr 19, 12:24 pm, wrote:
Function GetSelectedCheckBoxes(toIndex As Integer)

Const cbName As String = "cbSelectOption"
Const fromIndex As Integer = 1

Dim Index As Integer
Dim Selected As New Collection

Dim cb As OLEObject
Dim controlName As String

For Index = fromIndex To toIndex
Dim theWorkSheet As Worksheet
Set theWorkSheet = ThisWorkbook.ActiveSheet
controlName = cbName & Index

Set cb = theWorkSheet.OLEObjects(controlName)
If (cb.Value = True) Then

Selected.Add theWorkSheet.Cells(cb.TopLeftCell.Row, 1).Value
End If
Next Index
Set GetSelectedCheckBoxes = Selected

End Function


I haven't fully tested it, so let me know if it doesn't work as
expected.

Cheers,
David

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
Up down arrow keys do not select cells if select locked cells unch roandrob Excel Discussion (Misc queries) 3 May 18th 09 12:48 AM
Select All checkboxes Nikki Excel Discussion (Misc queries) 5 June 4th 08 12:47 AM
series of Checkboxes to select worksheet's data brucelim80[_10_] Excel Programming 4 March 28th 06 01:30 AM
How to select checkBoxes as a group in Fendic[_3_] Excel Programming 1 June 7th 05 02:43 AM
How to create in a userform, select all/deselect all checkboxes Intruder Excel Programming 1 July 31st 03 04:53 AM


All times are GMT +1. The time now is 07:46 AM.

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

About Us

"It's about Microsoft Excel"