ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Null in a ComboBox.List (https://www.excelbanter.com/excel-programming/398941-null-combobox-list.html)

LuisE

Null in a ComboBox.List
 
I'm looping thru a combobox list it works fine but at the end shows a Null
error.
I tried adding " -1" at the end but won't work either since all the items
are all strings

For Each ccc In CbxAddress.List
MsgBox ccc
Next ccc


Thanks in advance

Leith Ross[_2_]

Null in a ComboBox.List
 
On Oct 8, 8:14 pm, LuisE wrote:
I'm looping thru a combobox list it works fine but at the end shows a Null
error.
I tried adding " -1" at the end but won't work either since all the items
are all strings

For Each ccc In CbxAddress.List
MsgBox ccc
Next ccc

Thanks in advance


Hello LuisE,

Here are the looping methods for both the Forms and Control Toolbox
controls.

Sub FormsComboBox()

Dim Itm

For Each Itm In ActiveSheet.DropDowns("Drop Down 1").List
MsgBox Itm
Next Itm

End Sub


Sub ToolboxComboBox()

Dim Cbo As Object
Dim Itm

Set Cbo = ActiveSheet.OLEObjects("ComboBox1").Object
For Each Itm In Cbo.List
MsgBox Itm
Next Itm

End Sub


Sincerely,
Leith Ross


LuisE

Null in a ComboBox.List
 
Thanks Leith

I continue having the same error message.
My Combobox is in a UserForm, loops thru the whole list and at last it the
variable shows Null

"Leith Ross" wrote:

On Oct 8, 8:14 pm, LuisE wrote:
I'm looping thru a combobox list it works fine but at the end shows a Null
error.
I tried adding " -1" at the end but won't work either since all the items
are all strings

For Each ccc In CbxAddress.List
MsgBox ccc
Next ccc

Thanks in advance


Hello LuisE,

Here are the looping methods for both the Forms and Control Toolbox
controls.

Sub FormsComboBox()

Dim Itm

For Each Itm In ActiveSheet.DropDowns("Drop Down 1").List
MsgBox Itm
Next Itm

End Sub


Sub ToolboxComboBox()

Dim Cbo As Object
Dim Itm

Set Cbo = ActiveSheet.OLEObjects("ComboBox1").Object
For Each Itm In Cbo.List
MsgBox Itm
Next Itm

End Sub


Sincerely,
Leith Ross




All times are GMT +1. The time now is 07:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com