Combobox Problem Re-Visited
I used this in a standard module:
Sub ShowIt()
Load UserForm1
UserForm1.ComboBox1.RowSource = "A1:A16"
UserForm1.Show
End Sub
and then used this change event for the combobox:
Sub ComboBox1_Change()
Dim myDesc As Variant
Dim comboVal As Long
Dim lookupTbl As Range
Set lookupTbl = Worksheets("Sheet1").Range("A1:B16")
comboVal = UserForm1.ComboBox1.Value
myDesc = Application.WorksheetFunction. _
VLookup(comboVal, lookupTbl, 2, False)
Label4.Caption = myDesc
End Sub
----
Just a note - in my test, the item codes are numerical
values, so I set the comboVal to Long data type.
HTH
Jason
Atlanta, GA
-----Original Message-----
Hi, and Happy New Year to one and All.
I am having and have had a problem with putting a
Combobox on a form in
Excel. I have the following code but when executed
nothing is listed in the
combobox for selection.
myDesc = WorksheetFunction.VLookup(ComboBox1.Value, _
Worksheets("Sheet1").Range("A1:B16"), 2,
False)
Label4.Caption = myDesc
This procedure has been put into, the Change, the Enter
the Enter and at one
time I put it into the BeforeUpdate event.
I have "Sheet1" set-up with a list of 16 "item codes" in
column "A" and 16
"Descriptions" in Column "B".
Label4 is to show the corresponding item Description,
when the item code is
selected.
Help please!
Thanks
Dean
.
|