LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default add multiple checkboxes to userform at runtime

I have a spreadsheet with a list of values in column Y that I want to
show up as checkboxes on a userform. The current code crashes when it
tries to add a caption to the checkbox. I get a runtime error "Could
not find the specified object"
The actual code would call a function to determine how many rows in
column Y which will vary, and I'll add code to size the form and
manipulate the checkboxes to fit.



Private Sub UserForm_Initialize()
Dim iRow As Integer
Dim iLeft As Integer
Dim ctlCheckBox As Control
Dim sName As String
dim iNumRows as integer

Worksheets("ModelList").Activate
iTop = 10
For iRow = 2 To iNumRows
If Cells(iRow, "Y") < "" Then
Set ctlCheckBox =
frmEditBom.Controls.Add("Forms.CheckBox.1", "cb" & iRow)
sName = "cb" & iRow

'I tried using ctlCheckBox sub for sName-same result

frmEditBom! sName.Caption = Cells(iRow, "Y")
frmEditBom!sName.Left = iLeft
frmEditBom!sName.Top = iTop
iTop = iTop + 10
End If
Next iRow
End Sub



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

 
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
Multiple checkboxes and aligning Dudedad Excel Discussion (Misc queries) 2 June 26th 07 07:28 PM
Multiple Checkboxes Annie Excel Discussion (Misc queries) 2 June 11th 07 05:06 PM
Userform Checkboxes gti_jobert Excel Discussion (Misc queries) 1 January 27th 06 01:21 PM
Userform with Checkboxes Greg B Excel Discussion (Misc queries) 5 November 27th 05 09:32 PM
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 09:49 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"