Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default list to populate ComboBox

I am attempting to fill a combo box with the list ow Named Ranges with names
that begin with "List*. I successfully get the names into a text box (see
commented out code below), but whrn I attempt to write it to the combobox, I
get "Object doesn't support prroperty or method."

How do I write the list to a commbo box?

Ultimately, I am going to use the selected name range to populate a
multi-select listbox (which is working with hard coded Named Range in it.)

Thanks in advance, you generous souls. I have indeeed searched the forum,
and it does look to me like I am doing this correctly.

Private Sub UserForm_Initialize()
Dim nMames As Names
Dim nName As Name
Dim r As Variant
r = ""
For Each nName In Application.ThisWorkbook.Names
If nName.Name Like "List*" Then
r = r & nName.Name & Chr(10)
End If
Next nName
'MsgBox r
Sheets("Sheet1").ComboBox1.List = r
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default list to populate ComboBox

I didn't test this, but the idea is to put the names into an array, then use
the array for the list.

Dim r As Variant, i As Long
For Each nName In Application.ThisWorkbook.Names
If nName.Name Like "List*" Then
i = i + 1
r(i) = nName.Name
End If
Next nName

"KIM W" wrote in message
...
I am attempting to fill a combo box with the list ow Named Ranges with
names
that begin with "List*. I successfully get the names into a text box (see
commented out code below), but whrn I attempt to write it to the combobox,
I
get "Object doesn't support prroperty or method."

How do I write the list to a commbo box?

Ultimately, I am going to use the selected name range to populate a
multi-select listbox (which is working with hard coded Named Range in it.)

Thanks in advance, you generous souls. I have indeeed searched the forum,
and it does look to me like I am doing this correctly.

Private Sub UserForm_Initialize()
Dim nMames As Names
Dim nName As Name
Dim r As Variant
r = ""
For Each nName In Application.ThisWorkbook.Names
If nName.Name Like "List*" Then
r = r & nName.Name & Chr(10)
End If
Next nName
'MsgBox r
Sheets("Sheet1").ComboBox1.List = r
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default list to populate ComboBox

I'm confused about what you're doing.

You're using the userform_initialize routine, but then populating a combobox on
a workhsheet.

I'm guessing that you really wanted to populate a combobox on that userform.

If that's correct:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()

Dim nName As Name
Dim myNames() As String
Dim iCtr As Long

iCtr = 0
For Each nName In ThisWorkbook.Names
If LCase(nName.Name) Like LCase("List*") Then
iCtr = iCtr + 1
ReDim Preserve myNames(1 To iCtr)
myNames(iCtr) = nName.Name
End If
Next nName

If iCtr = 0 Then
Me.ComboBox1.Enabled = False
Else
With Me.ComboBox1
.List = myNames
.Enabled = True
End With
End If

End Sub

KIM W wrote:

I am attempting to fill a combo box with the list ow Named Ranges with names
that begin with "List*. I successfully get the names into a text box (see
commented out code below), but whrn I attempt to write it to the combobox, I
get "Object doesn't support prroperty or method."

How do I write the list to a commbo box?

Ultimately, I am going to use the selected name range to populate a
multi-select listbox (which is working with hard coded Named Range in it.)

Thanks in advance, you generous souls. I have indeeed searched the forum,
and it does look to me like I am doing this correctly.

Private Sub UserForm_Initialize()
Dim nMames As Names
Dim nName As Name
Dim r As Variant
r = ""
For Each nName In Application.ThisWorkbook.Names
If nName.Name Like "List*" Then
r = r & nName.Name & Chr(10)
End If
Next nName
'MsgBox r
Sheets("Sheet1").ComboBox1.List = r
End Sub


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default list to populate ComboBox

With your help, Dave, I now have it. Thanks for getting beyond my
misunderstanding and giving me a great workable solution.

"Dave Peterson" wrote:

I'm confused about what you're doing.

You're using the userform_initialize routine, but then populating a combobox on
a workhsheet.

I'm guessing that you really wanted to populate a combobox on that userform.

If that's correct:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()

Dim nName As Name
Dim myNames() As String
Dim iCtr As Long

iCtr = 0
For Each nName In ThisWorkbook.Names
If LCase(nName.Name) Like LCase("List*") Then
iCtr = iCtr + 1
ReDim Preserve myNames(1 To iCtr)
myNames(iCtr) = nName.Name
End If
Next nName

If iCtr = 0 Then
Me.ComboBox1.Enabled = False
Else
With Me.ComboBox1
.List = myNames
.Enabled = True
End With
End If

End Sub

KIM W wrote:

I am attempting to fill a combo box with the list ow Named Ranges with names
that begin with "List*. I successfully get the names into a text box (see
commented out code below), but whrn I attempt to write it to the combobox, I
get "Object doesn't support prroperty or method."

How do I write the list to a commbo box?

Ultimately, I am going to use the selected name range to populate a
multi-select listbox (which is working with hard coded Named Range in it.)

Thanks in advance, you generous souls. I have indeeed searched the forum,
and it does look to me like I am doing this correctly.

Private Sub UserForm_Initialize()
Dim nMames As Names
Dim nName As Name
Dim r As Variant
r = ""
For Each nName In Application.ThisWorkbook.Names
If nName.Name Like "List*" Then
r = r & nName.Name & Chr(10)
End If
Next nName
'MsgBox r
Sheets("Sheet1").ComboBox1.List = r
End Sub


--

Dave Peterson

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
Populate ComboBox list with Access data IT_roofer Excel Programming 10 April 11th 07 11:31 PM
Populate a ComboBox Greg Maxey[_3_] Excel Programming 3 March 22nd 07 06:23 PM
use selected value from one combobox to populate another combobox rjudge[_7_] Excel Programming 3 April 14th 06 02:01 PM
how to populate a combobox with a list of unique values? RIOSGER Excel Programming 2 August 9th 05 04:16 AM
Populate unique list in combobox Mark Excel Programming 3 July 26th 05 09:27 AM


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