michaelroshan
New Member
- Joined
- Jun 27, 2020
- Messages
- 16
- Office Version
- 2007
- Platform
- Windows
Dear Friends,
I am working on a Form to retrieve data on an Inventory data sheet using the serial numbers that look like this "CL/SBR/08" the item count is around 3000 and on a daily basis i need to update incoming and out going stock based on the serial number.
(1) i need to be able to retrieve data to a userform entering this serial# to a combobox or textbox and retrieve the details.
(2) then i want to change the values on the data in the same form and click update, so that the edited data will be updated on the same row that has the serial# in the sheet.
I am not a VBA expert and i have no experience at all! so i gather coding from google, put them together and make this.
the coding i have is below! please help me to organise this and get it running. THANKS A MILLION.
[/COLOR][/B]
I am working on a Form to retrieve data on an Inventory data sheet using the serial numbers that look like this "CL/SBR/08" the item count is around 3000 and on a daily basis i need to update incoming and out going stock based on the serial number.
(1) i need to be able to retrieve data to a userform entering this serial# to a combobox or textbox and retrieve the details.
(2) then i want to change the values on the data in the same form and click update, so that the edited data will be updated on the same row that has the serial# in the sheet.
I am not a VBA expert and i have no experience at all! so i gather coding from google, put them together and make this.
the coding i have is below! please help me to organise this and get it running. THANKS A MILLION.
VBA Code:
Private Sub CommandButton1_Click()
If Me.ComboBox1.Value = "" Then
MsgBox "Month Cannot be Blank!!!", vbExclamation, "Item Code"
Exit Sub
End If
Dim rowselect As Double
Dim z As Integer
z = Me.PartNumberComboBox.Value
Sheets("Inventory Data").Select
rowselect = ComboBox2.Value
rowselect = rowselect + 5
Rows(rowselect).Select
'Cells(rowselect, 1) = Me.ComboBox2.Value
'Cells(rowselect, 2) = Me.DescriptionBox.Value
'Cells(rowselect, 3) = Me.CCBox.Value
If ComboBox1 = "JAN" Then
Cells(rowselect, 5) = Me.RcvdBox.Value
Cells(rowselect, 6) = Me.IssueBox.Value
End If
If ComboBox1 = "FEB" Then
Cells(rowselect, 8) = Me.RcvdBox.Value
Cells(rowselect, 9) = Me.IssueBox.Value
End If
If ComboBox1 = "MAR" Then
Cells(rowselect, 11) = Me.RcvdBox.Value
Cells(rowselect, 12) = Me.IssueBox.Value
End If
If ComboBox1 = "APR" Then
Cells(rowselect, 14) = Me.RcvdBox.Value
Cells(rowselect, 15) = Me.IssueBox.Value
End If
If ComboBox1 = "MAY" Then
Cells(rowselect, 17) = Me.RcvdBox.Value
Cells(rowselect, 18) = Me.IssueBox.Value
End If
If ComboBox1 = "JUN" Then
Cells(rowselect, 20) = Me.RcvdBox.Value
Cells(rowselect, 21) = Me.IssueBox.Value
End If
If ComboBox1 = "JUL" Then
Cells(rowselect, 23) = Me.RcvdBox.Value
Cells(rowselect, 24) = Me.IssueBox.Value
End If
If ComboBox1 = "AUG" Then
Cells(rowselect, 26) = Me.RcvdBox.Value
Cells(rowselect, 27) = Me.IssueBox.Value
End If
If ComboBox1 = "SEP" Then
Cells(rowselect, 29) = Me.RcvdBox.Value
Cells(rowselect, 30) = Me.IssueBox.Value
End If
If ComboBox1 = "OCT" Then
Cells(rowselect, 32) = Me.RcvdBox.Value
Cells(rowselect, 33) = Me.IssueBox.Value
End If
If ComboBox1 = "NOV" Then
Cells(rowselect, 35) = Me.RcvdBox.Value
Cells(rowselect, 36) = Me.IssueBox.Value
End If
If ComboBox1 = "DEC" Then
Cells(rowselect, 38) = Me.RcvdBox.Value
Cells(rowselect, 39) = Me.IssueBox.Value
End If
rowselect = rowselect - 1
msg = "Data Successfully Updated...Continue?"
Unload Me
ans = MsgBox(msg, vbYesNo, "Update")
If ans = vbYes Then
FormInvUpdate.Show
Else
Sheets("Inventory Data").Select
End If
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.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
End Sub
Private Sub ComboBox2_Change()
Dim z As Integer
Dim lookupRange As Range
Dim ComboBox2 As Variant
Set lookupRange = Worksheets("Inventory Data").Range("$A$5:$D$7000")
If Me.ComboBox2.Value = "" Then
MsgBox "Please Enter Item Code to Update!!!", vbExclamation, "Item Code!"
Exit Sub
End If
z = Me.ComboBox2.Text
On Error Resume Next
'Me.ComboBox2.Value = Application.WorksheetFunction.VLookup(z, Sheets("Inventory Data").Range("A5:D7000"), 1, 0)
Me.DescriptionBox.Value = Application.WorksheetFunction.VLookup(z, Sheets("Inventory Data").Range("A5:D7000"), 2, 0)
Me.CCBox.Value = Application.WorksheetFunction.VLookup(z, Sheets("Inventory Data").Range("A5:D7000"), 3, 0)
Me.BalBox.Value = Application.WorksheetFunction.VLookup(z, Sheets("Inventory Data").Range("A5:d7000"), 40, 0)[/B][/COLOR]
End Sub
Last edited by a moderator: