![]() |
Combo box
I have a variable named WhichCombo. This has a name of a combo box it in to
be used in the statment below. When I try this there is an error. How do I use the variable in the statment below for the combo box? Sheets("Sheet1").WhichCombo.AddItem Item |
Combo box
I used a combobox from the Control Toolbox toolbar. Is that what you used?
Option Explicit Sub testme02() Dim WhichCombo As String Dim myItem As String WhichCombo = "Combobox1" myItem = "hi there" Worksheets("Sheet1").OLEObjects(WhichCombo).Object .AddItem myItem End Sub Item looks too much like VBA's .Item property. I wouldn't use it as a variable name. pokdbz wrote: I have a variable named WhichCombo. This has a name of a combo box it in to be used in the statment below. When I try this there is an error. How do I use the variable in the statment below for the combo box? Sheets("Sheet1").WhichCombo.AddItem Item -- Dave Peterson |
Combo box
Yep thats what I needed.
"Dave Peterson" wrote: I used a combobox from the Control Toolbox toolbar. Is that what you used? Option Explicit Sub testme02() Dim WhichCombo As String Dim myItem As String WhichCombo = "Combobox1" myItem = "hi there" Worksheets("Sheet1").OLEObjects(WhichCombo).Object .AddItem myItem End Sub Item looks too much like VBA's .Item property. I wouldn't use it as a variable name. pokdbz wrote: I have a variable named WhichCombo. This has a name of a combo box it in to be used in the statment below. When I try this there is an error. How do I use the variable in the statment below for the combo box? Sheets("Sheet1").WhichCombo.AddItem Item -- Dave Peterson |
All times are GMT +1. The time now is 12:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com