Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Stuffing Multiple Checkbox Captions

I have a user form with 20 check boxes. I want to loop through them stuffing
the captions with various text retrieved from a worksheet.

The checkboxes are consecutively named checkbox1 to checkbox 20.

for i = 1 to 20 step 1

what goes here?

next i

Thanks,

Sandy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Stuffing Multiple Checkbox Captions

Sandy

For i = 1 To 2
Me.Controls("CheckBox" & i).Caption = "Test" & i
Next i

hth,

Doug

"Sandy" wrote in message
...
I have a user form with 20 check boxes. I want to loop through them
stuffing
the captions with various text retrieved from a worksheet.

The checkboxes are consecutively named checkbox1 to checkbox 20.

for i = 1 to 20 step 1

what goes here?

next i

Thanks,

Sandy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Stuffing Multiple Checkbox Captions

Sandy-

Try this for starters:

Sub Fill_Captions()
Dim ctrl As MSForms.Control
Dim i As Integer
i = 1
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
ctrl.Caption = Sheets(1).Cells(i, "A")
i = i + 1
End If
Next
End Sub

---
This assumes the captions you want to use in cells A1:A20 in the first sheet
of your workbook.

HTH
Jason
Atlanta, GA


"Sandy" wrote:

I have a user form with 20 check boxes. I want to loop through them stuffing
the captions with various text retrieved from a worksheet.

The checkboxes are consecutively named checkbox1 to checkbox 20.

for i = 1 to 20 step 1

what goes here?

next i

Thanks,

Sandy

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Stuffing Multiple Checkbox Captions

Jason, likewise how would I set the value to True or False? I tried changing
..Caption to .Value but that didn't work.

Thank you,

Sandy

"Jason Morin" wrote:

Sandy-

Try this for starters:

Sub Fill_Captions()
Dim ctrl As MSForms.Control
Dim i As Integer
i = 1
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
ctrl.Caption = Sheets(1).Cells(i, "A")
i = i + 1
End If
Next
End Sub

---
This assumes the captions you want to use in cells A1:A20 in the first sheet
of your workbook.

HTH
Jason
Atlanta, GA


"Sandy" wrote:

I have a user form with 20 check boxes. I want to loop through them stuffing
the captions with various text retrieved from a worksheet.

The checkboxes are consecutively named checkbox1 to checkbox 20.

for i = 1 to 20 step 1

what goes here?

next i

Thanks,

Sandy

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Stuffing Multiple Checkbox Captions

Hi Sandy,

I don't now why that doesn't work for you, it does for me, -
i = 0
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
i = i + 1
ctrl.Caption = Sheets(1).Cells(i, "A")
ctrl.Value = Sheets(1).Cells(i, "B")
End If
Next

If you want to store values between sessions you could 'link' to a cell with
ControlSurce, in Col-C perhaps.

With 20 similar controls probably worth setting up a collection or array of
'WithEvent' class.

Regards,
Peter T


"Sandy" wrote in message
...
Jason, likewise how would I set the value to True or False? I tried

changing
.Caption to .Value but that didn't work.

Thank you,

Sandy

"Jason Morin" wrote:

Sandy-

Try this for starters:

Sub Fill_Captions()
Dim ctrl As MSForms.Control
Dim i As Integer
i = 1
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
ctrl.Caption = Sheets(1).Cells(i, "A")
i = i + 1
End If
Next
End Sub

---
This assumes the captions you want to use in cells A1:A20 in the first

sheet
of your workbook.

HTH
Jason
Atlanta, GA


"Sandy" wrote:

I have a user form with 20 check boxes. I want to loop through them

stuffing
the captions with various text retrieved from a worksheet.

The checkboxes are consecutively named checkbox1 to checkbox 20.

for i = 1 to 20 step 1

what goes here?

next i

Thanks,

Sandy





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
X axis captions Stefi Charts and Charting in Excel 6 September 11th 08 01:16 PM
Allow multiple selections within a checkbox of items shawna New Users to Excel 1 January 8th 08 02:42 PM
How to automate datasheet stuffing? Karl Excel Worksheet Functions 1 July 17th 07 12:02 AM
Stuffing Numeric Variable Values into Footnote with formatting Dkline[_3_] Excel Programming 2 August 15th 05 09:44 PM
Stuffing a picture into a header DRK Excel Programming 2 June 16th 05 06:37 PM


All times are GMT +1. The time now is 07:38 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"