JeremyA1976
Board Regular
- Joined
- Aug 3, 2015
- Messages
- 59
I am trying to auto-update label ("label9) from userform1 based on the description chosen from a combobox ("mt").
I have a worksheet ("Lists") that contains all the descriptions that populate a combobox in my userform1 starting at cell A1 and going down. Starting in cell C1, I have a corresponding prefix code for that description we use in our tracking number. When I initialize my userform1, then choose "Galvanized" (for example) from the list, I want Label9 to automatically change to its corresponding prefix code.
My userform1 initialize code:
other code:
I have tried and failed all morning at trying to figure this out for myself, figured it was a good time to bring in the gurus. Thanks in advance.
I have a worksheet ("Lists") that contains all the descriptions that populate a combobox in my userform1 starting at cell A1 and going down. Starting in cell C1, I have a corresponding prefix code for that description we use in our tracking number. When I initialize my userform1, then choose "Galvanized" (for example) from the list, I want Label9 to automatically change to its corresponding prefix code.
My userform1 initialize code:
Code:
Private Sub UserForm_Initialize()
Dim wsLists As Worksheet
Dim ws As Worksheet
Dim TypeList As Variant, SizeList As Variant
'Dim result As Variant
Set wsLists = ThisWorkbook.Worksheets("lists")
'result = Application.VLookup(mt.Value, Range("A1:C15"), 3, False)
With wsLists
TypeList = .Range(.Range("A1"), .Range("A" & .Rows.Count).End(xlUp)).Value2
SizeList = .Range(.Range("B1"), .Range("B" & .Rows.Count).End(xlUp)).Value2
End With
'Dim iRow As Long
'iRow = WorksheetFunction.Match(mt.Value, Range("metalnames").Columns(1).Cells)
'Label9.Caption = result.Value
mt.List = TypeList
MThk.List = SizeList
AddLists Me
End Sub
other code:
Code:
Sub AddLists(ByVal Form As Object) Dim wsLists As Worksheet
Dim TypeList As Variant, SizeList As Variant
Set wsLists = ThisWorkbook.Worksheets("lists")
With wsLists
TypeList = .Range(.Range("A1"), .Range("A" & .Rows.Count).End(xlUp)).Value2
SizeList = .Range(.Range("B1"), .Range("B" & .Rows.Count).End(xlUp)).Value2
End With
Form.mt.List = TypeList
Form.MThk.List = SizeList
End Sub
I have tried and failed all morning at trying to figure this out for myself, figured it was a good time to bring in the gurus. Thanks in advance.