ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA - Capturing a checkbox caption into a worksheet. (https://www.excelbanter.com/excel-programming/301917-excel-vba-capturing-checkbox-caption-into-worksheet.html)

rott[_9_]

Excel VBA - Capturing a checkbox caption into a worksheet.
 
Hi
This is what I am trying to do. I have about 170 checkboxes on
worksheet. What I want to happen is when I select certain checkboxes
then click a command button, it will pull the caption off eac
selected checkbox and will populate it into another worksheet in colum
A starting on line 3 in a list format.

Can anyone think of a way this can be done?

Any help would be greatly appreciated because I am at a loss and I a
reaching a deadline.

thanks
rot

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

Excel VBA - Capturing a checkbox caption into a worksheet.
 
There are 2 different types of checkboxes that you can have on a worksheet--one
is from the Forms toolbar and the other is from the Control toolbox toolbar:

Option Explicit
Sub testme()

Dim CBX As CheckBox 'from the Forms toolbar
Dim oRow As Long

oRow = 2
For Each CBX In Worksheets("sheet1").CheckBoxes
If CBX.Value = xlOn Then
oRow = oRow + 1
Worksheets("sheet2").Cells(oRow, "A").Value _
= CBX.Caption
End If
Next CBX
End Sub


Sub testme2()

Dim OLEObj As OLEObject
Dim oRow As Long

oRow = 2
For Each OLEObj In Worksheets("Sheet1").OLEObjects
If TypeOf OLEObj.Object Is msforms.CheckBox Then
If OLEObj.Object.Value = True Then
oRow = oRow + 1
Worksheets("sheet2").Cells(oRow, "A").Value _
= OLEObj.Object.Caption
End If
End If
Next OLEObj
End Sub


"rott <" wrote:

Hi
This is what I am trying to do. I have about 170 checkboxes on a
worksheet. What I want to happen is when I select certain checkboxes,
then click a command button, it will pull the caption off each
selected checkbox and will populate it into another worksheet in column
A starting on line 3 in a list format.

Can anyone think of a way this can be done?

Any help would be greatly appreciated because I am at a loss and I am
reaching a deadline.

thanks
rott

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



All times are GMT +1. The time now is 08:19 AM.

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