michaelroshan
New Member
- Joined
- Jun 27, 2020
- Messages
- 16
- Office Version
- 2007
- Platform
- Windows
Hi,
I am looking for the code for the attached userform!,
Item Code and Item Name are drop down lists from a Range,
i am looking to use the Item Name drop down to change the value of the item code when i change the value of Item Name.! I have already got the codeing done to change the Item name and Unit to change when i change the value of the Item Code.
How do i get both of them done? ... the Code is below
I am looking for the code for the attached userform!,
Item Code and Item Name are drop down lists from a Range,
i am looking to use the Item Name drop down to change the value of the item code when i change the value of Item Name.! I have already got the codeing done to change the Item name and Unit to change when i change the value of the Item Code.
How do i get both of them done? ... the Code is below
Rich (BB code):
Private Sub UserForm_Initialize()
Set sh = Sheets("2021")
With MonthBox2
.AddItem "JAN"
.AddItem "FEB"
.AddItem "MAR"
.AddItem "APR"
.AddItem "MAY"
.AddItem "JUN"
.AddItem "JUL"
.AddItem "AUG"
.AddItem "SEP"
.AddItem "OCT"
.AddItem "NOV"
.AddItem "DEC"
End With
With CCBox2
.AddItem ""
.AddItem "MAZ"
.AddItem "RHQ"
.AddItem "RCG"
.AddItem "RES"
.AddItem "CC"
End With
'Next
ItemBox2.List = sh.Range("B5", sh.Range("B" & Rows.Count).End(3)).Value
NameBox2.List = sh.Range("C5", sh.Range("C" & Rows.Count).End(3)).Value
End Sub
Private Sub NameBox2_Change()
RunObject Me.NameBox2
End Sub
Private Sub ItemBox2_Change()
RunObject Me.ItemBox2
End Sub
Private Sub CCBox2_Change()
RunObject Me.CCBox2
End Sub
Private Sub MonthBox2_Change()
RunObject Me.MonthBox2
End Sub
Private Sub RunObject(object)
Dim sr As String, nm As String
Dim lookupRange As Range
'Dim ItemBox As Variant
'Dim MonthBox As Variant
'Dim CCBox As Variant
Set lookupRange = Worksheets("2021").Range("$B$5:$CWI$7000")
'If Me.ItemBox2.Value = "" Then
'MsgBox "Please Enter Item Code to Update!!!", vbExclamation, "Item Code!"
'Exit Sub
'End If
sr = Me.ItemBox2.Value
nm = Me.NameBox2.Value
On Error Resume Next
Me.ItemBox2.Value = Application.WorksheetFunction.VLookup(nm, lookupRange, 1, 0)
Me.NameBox2.Value = Application.WorksheetFunction.VLookup(sr, lookupRange, 2, 0)
Me.UnitBox2.Value = Application.WorksheetFunction.VLookup(sr, lookupRange, 3, 0)
Me.masterBalanceLabel = Application.WorksheetFunction.VLookup(sr, lookupRange, 201, 0)
Attachments
Last edited: