Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Variable Range, Control ToolBox ComboBox

Is it possible to assign a variable range to an Embeded Control Toolbox
ComboBox? If so, how? Here's the code I've been trying to get to work.

Private Sub Workbook_Open()
Dim IMDS As Worksheet
Dim CB1 As OLEObject
Dim AllCT As Range
Dim i As Integer

Set IMDS = Workbooks("IMDS Calc.xls").Worksheets("IMDS")
Set CB1 = IMDS.OLEObjects("ComboBox1")

For i = 2 To 20
If IMDS.Range("AA" & i).Value = "" Then GoTo Line1
Next i
Line1:
Set AllCT = IMDS.Range("AA2:AA" & i - 1)
CB1.ListFillRange = AllCT
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Variable Range, Control ToolBox ComboBox

List fill range takes a string not a range object. That being said give this
a look...

Private Sub Workbook_Open()
Dim IMDS As Worksheet
Dim CB1 As ComboBox
Dim AllCT As Range

Set IMDS = Workbooks("IMDS Calc.xls").Worksheets("IMDS")
Set CB1 = IMDS.ComboBox1

With IMDS
Set AllCT = .Range(.Range("AA2"), .Range("AA2").End(xlDown))
End With
CB1.ListFillRange = AllCT.Address
End Sub
--
HTH...

Jim Thomlinson


"JayWes" wrote:

Is it possible to assign a variable range to an Embeded Control Toolbox
ComboBox? If so, how? Here's the code I've been trying to get to work.

Private Sub Workbook_Open()
Dim IMDS As Worksheet
Dim CB1 As OLEObject
Dim AllCT As Range
Dim i As Integer

Set IMDS = Workbooks("IMDS Calc.xls").Worksheets("IMDS")
Set CB1 = IMDS.OLEObjects("ComboBox1")

For i = 2 To 20
If IMDS.Range("AA" & i).Value = "" Then GoTo Line1
Next i
Line1:
Set AllCT = IMDS.Range("AA2:AA" & i - 1)
CB1.ListFillRange = AllCT
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Variable Range, Control ToolBox ComboBox

If you are dealing with an external workbook you may need to change
Set CB1 = IMDS.ComboBox1
to
Set CB1 = IMDS.OLEObjects("ComboBox1")

--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

List fill range takes a string not a range object. That being said give this
a look...

Private Sub Workbook_Open()
Dim IMDS As Worksheet
Dim CB1 As ComboBox
Dim AllCT As Range

Set IMDS = Workbooks("IMDS Calc.xls").Worksheets("IMDS")
Set CB1 = IMDS.ComboBox1

With IMDS
Set AllCT = .Range(.Range("AA2"), .Range("AA2").End(xlDown))
End With
CB1.ListFillRange = AllCT.Address
End Sub
--
HTH...

Jim Thomlinson


"JayWes" wrote:

Is it possible to assign a variable range to an Embeded Control Toolbox
ComboBox? If so, how? Here's the code I've been trying to get to work.

Private Sub Workbook_Open()
Dim IMDS As Worksheet
Dim CB1 As OLEObject
Dim AllCT As Range
Dim i As Integer

Set IMDS = Workbooks("IMDS Calc.xls").Worksheets("IMDS")
Set CB1 = IMDS.OLEObjects("ComboBox1")

For i = 2 To 20
If IMDS.Range("AA" & i).Value = "" Then GoTo Line1
Next i
Line1:
Set AllCT = IMDS.Range("AA2:AA" & i - 1)
CB1.ListFillRange = AllCT
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Variable Range, Control ToolBox ComboBox

Jim,

Thanks for the response, but the code gets hung up he

Set CB1 = IMDS.ComboBox1

I get a message box saying, "Method or data member not found"

Any ideas why?


"Jim Thomlinson" wrote:

List fill range takes a string not a range object. That being said give this
a look...

Private Sub Workbook_Open()
Dim IMDS As Worksheet
Dim CB1 As ComboBox
Dim AllCT As Range

Set IMDS = Workbooks("IMDS Calc.xls").Worksheets("IMDS")
Set CB1 = IMDS.ComboBox1

With IMDS
Set AllCT = .Range(.Range("AA2"), .Range("AA2").End(xlDown))
End With
CB1.ListFillRange = AllCT.Address
End Sub
--
HTH...

Jim Thomlinson


"JayWes" wrote:

Is it possible to assign a variable range to an Embeded Control Toolbox
ComboBox? If so, how? Here's the code I've been trying to get to work.

Private Sub Workbook_Open()
Dim IMDS As Worksheet
Dim CB1 As OLEObject
Dim AllCT As Range
Dim i As Integer

Set IMDS = Workbooks("IMDS Calc.xls").Worksheets("IMDS")
Set CB1 = IMDS.OLEObjects("ComboBox1")

For i = 2 To 20
If IMDS.Range("AA" & i).Value = "" Then GoTo Line1
Next i
Line1:
Set AllCT = IMDS.Range("AA2:AA" & i - 1)
CB1.ListFillRange = AllCT
End Sub

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
Control ToolBox ComboBox Steve D Excel Discussion (Misc queries) 1 July 1st 09 05:17 PM
Is it possible to create a dynamic range in CONTROL TOOLBOX (form) [email protected] Excel Discussion (Misc queries) 7 July 27th 07 07:28 AM
Can Combobox range be variable? Matt[_33_] Excel Programming 3 October 6th 05 08:15 PM
Problem: Control Toolbox Control resizes when clicked Ed Excel Programming 1 July 27th 05 07:55 AM
Controls Toolbox control vs Form Toolbox control Tony_VBACoder Excel Programming 3 January 28th 05 08:30 AM


All times are GMT +1. The time now is 12:18 AM.

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"