ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to enter variable in combobox (https://www.excelbanter.com/excel-programming/346483-macro-enter-variable-combobox.html)

Mervb

macro to enter variable in combobox
 
(Using VBA) I have a userForm which contains a ComboBox - data can be entered
into the Userform manually or via a macro (ie. some of the data is contained
in variables). How can I use a variable to make an entry in a Combo box - I
am not talking of creating a range etc. - think of it as if a user was
entering text via the keyboard.

MervB
:-)

Rowan Drummond[_3_]

macro to enter variable in combobox
 
Try:

Dim myStr As String
myStr = "The Value"
Me.ComboBox1.AddItem myStr


Hope this helps
Rowan

MervB wrote:
(Using VBA) I have a userForm which contains a ComboBox - data can be entered
into the Userform manually or via a macro (ie. some of the data is contained
in variables). How can I use a variable to make an entry in a Combo box - I
am not talking of creating a range etc. - think of it as if a user was
entering text via the keyboard.

MervB
:-)


Mervb

macro to enter variable in combobox
 
Tanks

"Rowan Drummond" wrote:

Try:

Dim myStr As String
myStr = "The Value"
Me.ComboBox1.AddItem myStr


Hope this helps
Rowan

MervB wrote:
(Using VBA) I have a userForm which contains a ComboBox - data can be entered
into the Userform manually or via a macro (ie. some of the data is contained
in variables). How can I use a variable to make an entry in a Combo box - I
am not talking of creating a range etc. - think of it as if a user was
entering text via the keyboard.

MervB
:-)




All times are GMT +1. The time now is 09:04 PM.

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