Strugglin Exceller
New Member
- Joined
- Mar 9, 2021
- Messages
- 13
- Office Version
- 365
- Platform
- Windows
So I have two userforms. one to add a quantity to inventory and one to subtract. In the userform, when you look up the part number. it will fill in a description of the part and the amount in inventory. If you enter a quantity in the add Field. it will take the number in inventory and add the quantity you are adding to the existing amount. My code works great for adding.
So i used the same code for removing inventory and it does a whacky calculation. if there are 200 in inventory and I want to remove a hundred. it changes the new total to -100
This is my code to add
This is my code to remove
You can see in the uploaded image what it's doing. I'm guessing I'm just overlooking something really simple
Thanks in advance for your help
So i used the same code for removing inventory and it does a whacky calculation. if there are 200 in inventory and I want to remove a hundred. it changes the new total to -100
This is my code to add
VBA Code:
Private Sub SubmitAdd_Click()
Dim Part_No As Long
Part_No = PartNo.Text
lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For I = 2 To lastrow
If Sheet1.Cells(I, 1).Value = Part_No Then
Sheet1.Cells(I, 32).Value = QtyAdd.Text + Sheet1.Cells(I, 32).Value
MsgBox "Your inventory quantity has been updated to " & Sheet1.Cells(I, 32).Value
End If
Next
Unload AddQtyToInv
End Sub
This is my code to remove
VBA Code:
Private Sub SubmitRemove_Click()
Dim Part_No As Long
Part_No = PartNo.Text
lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For I = 2 To lastrow
If Sheet1.Cells(I, 1).Value = Part_No Then
Sheet1.Cells(I, 32).Value = QtyRemoved.Text - Sheet1.Cells(I, 32).Value
MsgBox "Your inventory quantity has been updated to " & Sheet1.Cells(I, 32).Value
End If
Next
Unload RemoveQtyFromInv
End Sub
You can see in the uploaded image what it's doing. I'm guessing I'm just overlooking something really simple
Thanks in advance for your help