Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Populate combobox

Hello
Why doesn't this populate my ActiveX combobox?

Private Sub ComboBox1_Change()
Dim row As Integer
' Make sure the RowSource property is empty
Sheet1!ComboBox1.RowSource = ""

Sheet1!ComboBox1.RowSource = "Sheet1!A1:A12"
' Add some items to the ActiveX combobox
For row = 1 To 12
Sheet1!ComboBox1.AddItem Sheets("Sheet1").Cells(row, 1)
Next row
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Populate combobox

Change the exclamation point (!) to a period (.) after Sheet1 everywhere
except in the row source reference that is within the quote marks.



"SteveZmyname" wrote in message
...
Hello
Why doesn't this populate my ActiveX combobox?

Private Sub ComboBox1_Change()
Dim row As Integer
' Make sure the RowSource property is empty
Sheet1!ComboBox1.RowSource = ""

Sheet1!ComboBox1.RowSource = "Sheet1!A1:A12"
' Add some items to the ActiveX combobox
For row = 1 To 12
Sheet1!ComboBox1.AddItem Sheets("Sheet1").Cells(row, 1)
Next row
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Populate combobox

hi
1. you are using the change event. with nothing in the combo box, nothing
changes so the code never runs.
2. Active X combo box uses the listfillrange. forms combobox uses the row
source.
3. you are attempting to use listfillrange and add item. 1 is enough, both
is redundent.
using listfillrange with worksheet activate event
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
'Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

you could use the workbook open event

regards
FSt1

"SteveZmyname" wrote:

Hello
Why doesn't this populate my ActiveX combobox?

Private Sub ComboBox1_Change()
Dim row As Integer
' Make sure the RowSource property is empty
Sheet1!ComboBox1.RowSource = ""

Sheet1!ComboBox1.RowSource = "Sheet1!A1:A12"
' Add some items to the ActiveX combobox
For row = 1 To 12
Sheet1!ComboBox1.AddItem Sheets("Sheet1").Cells(row, 1)
Next row
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Populate combobox

Hi
This code didn't populate my combobox...
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

nor did this...
'using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

I noticed c wasn't dimmed or set to anything. I think c must be a counter?

"FSt1" wrote:

hi
1. you are using the change event. with nothing in the combo box, nothing
changes so the code never runs.
2. Active X combo box uses the listfillrange. forms combobox uses the row
source.
3. you are attempting to use listfillrange and add item. 1 is enough, both
is redundent.
using listfillrange with worksheet activate event
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
'Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

you could use the workbook open event

regards
FSt1

"SteveZmyname" wrote:

Hello
Why doesn't this populate my ActiveX combobox?

Private Sub ComboBox1_Change()
Dim row As Integer
' Make sure the RowSource property is empty
Sheet1!ComboBox1.RowSource = ""

Sheet1!ComboBox1.RowSource = "Sheet1!A1:A12"
' Add some items to the ActiveX combobox
For row = 1 To 12
Sheet1!ComboBox1.AddItem Sheets("Sheet1").Cells(row, 1)
Next row
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Populate combobox

hi
both methods worked perfictly in my 2003 excel. not sure why it's not
working for you.
did you put the code in the the sheet that owns the combo box. it wont work
if it's in a standard module or workbook module.

regards
FST1

"SteveZmyname" wrote:

Hi
This code didn't populate my combobox...
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

nor did this...
'using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

I noticed c wasn't dimmed or set to anything. I think c must be a counter?

"FSt1" wrote:

hi
1. you are using the change event. with nothing in the combo box, nothing
changes so the code never runs.
2. Active X combo box uses the listfillrange. forms combobox uses the row
source.
3. you are attempting to use listfillrange and add item. 1 is enough, both
is redundent.
using listfillrange with worksheet activate event
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
'Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

you could use the workbook open event

regards
FSt1

"SteveZmyname" wrote:

Hello
Why doesn't this populate my ActiveX combobox?

Private Sub ComboBox1_Change()
Dim row As Integer
' Make sure the RowSource property is empty
Sheet1!ComboBox1.RowSource = ""

Sheet1!ComboBox1.RowSource = "Sheet1!A1:A12"
' Add some items to the ActiveX combobox
For row = 1 To 12
Sheet1!ComboBox1.AddItem Sheets("Sheet1").Cells(row, 1)
Next row
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Populate combobox

You are probably using the combobox from the Forms toolbar. It would work
if you used the combobox from the control toolbox and the combobox name is
in fact CombBox1.


"SteveZmyname" wrote in message
...
Hi
This code didn't populate my combobox...
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

nor did this...
'using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

I noticed c wasn't dimmed or set to anything. I think c must be a counter?

"FSt1" wrote:

hi
1. you are using the change event. with nothing in the combo box, nothing
changes so the code never runs.
2. Active X combo box uses the listfillrange. forms combobox uses the row
source.
3. you are attempting to use listfillrange and add item. 1 is enough,
both
is redundent.
using listfillrange with worksheet activate event
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
'Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

you could use the workbook open event

regards
FSt1

"SteveZmyname" wrote:

Hello
Why doesn't this populate my ActiveX combobox?

Private Sub ComboBox1_Change()
Dim row As Integer
' Make sure the RowSource property is empty
Sheet1!ComboBox1.RowSource = ""

Sheet1!ComboBox1.RowSource = "Sheet1!A1:A12"
' Add some items to the ActiveX combobox
For row = 1 To 12
Sheet1!ComboBox1.AddItem Sheets("Sheet1").Cells(row, 1)
Next row
End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Populate combobox

Hi
I'm using Insert from the ribbon, then Combobox from the lower half of the
toolbox that is the ActiveX portion. The code is within sheet1 not a module.
But, it still is not populating the control.

I went so far as to open a new book and insert the control and code.

I'm using...
'using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

thanks for your help. It's probably some small detail I'm overlooking.

"JLGWhiz" wrote:

You are probably using the combobox from the Forms toolbar. It would work
if you used the combobox from the control toolbox and the combobox name is
in fact CombBox1.


"SteveZmyname" wrote in message
...
Hi
This code didn't populate my combobox...
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

nor did this...
'using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

I noticed c wasn't dimmed or set to anything. I think c must be a counter?

"FSt1" wrote:

hi
1. you are using the change event. with nothing in the combo box, nothing
changes so the code never runs.
2. Active X combo box uses the listfillrange. forms combobox uses the row
source.
3. you are attempting to use listfillrange and add item. 1 is enough,
both
is redundent.
using listfillrange with worksheet activate event
Private Sub Worksheet_Activate()
' Make sure the RowSource property is empty
Sheet1.ComboBox1.ListFillRange = ""
'Sheet1.ComboBox1.ListFillRange = "A1:A12"
End Sub

using the for next loop with worksheet activate event
Private Sub Worksheet_Activate()
Dim r As Range
Set r = Range("A1:A12")
ComboBox1.Clear
' Add some items to the ActiveX combobox
For Each c In r
ComboBox1.AddItem c.Value
Next c
End Sub

you could use the workbook open event

regards
FSt1

"SteveZmyname" wrote:

Hello
Why doesn't this populate my ActiveX combobox?

Private Sub ComboBox1_Change()
Dim row As Integer
' Make sure the RowSource property is empty
Sheet1!ComboBox1.RowSource = ""

Sheet1!ComboBox1.RowSource = "Sheet1!A1:A12"
' Add some items to the ActiveX combobox
For row = 1 To 12
Sheet1!ComboBox1.AddItem Sheets("Sheet1").Cells(row, 1)
Next row
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
POPULATE combobox sunilpatel Excel Programming 2 April 24th 09 01:07 PM
Populate combobox with sql from DAO dan dungan Excel Programming 1 January 29th 09 10:12 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
Populate a combobox Rory[_3_] Excel Programming 2 June 9th 04 04:20 PM


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