Updating Inventory

himanshuvrat

New Member
Joined
Nov 6, 2017
Messages
1
I want to shift quantity of ‘Items’ from worksheet “Invoice” to Worksheet “Purchase” in column Named as ‘Balance Quantity’ where it will be deducted from initially available quantity of invoiced item in corresponding row to the ‘Item’ of sale. This quantity of ‘Item’ will also be transferred to Worksheet “Purchase” in column Named as ‘Total Sale’ in corresponding row to the invoiced ‘Item’, where it will be added every time when this item is invoiced and invoice is printed.
The ‘Item Names’ in worksheet “Purchase” is in Column “A” starting from “A2”which has nearly 770 items. The ‘Balance quantity’ is shown in Column “H”. The ‘Total Sales’ is shown in column “I”
The ‘Item Names’ in Work Sheet “Invoice“ is in Column “A” from “A12 to A30” . The invoice may contain any number of items ranging from minimum 1 to maximum 21 , out of all the 770 items contained in worksheet “Purchase. Quantity of Items is in Column “B” from “B12” to “B30”
The VBA code for the above I have written is as follows but it did not run.
Sub UpdateInventory()
Dim x As Long
Dim r As Long
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim newQuantity As Long
Set ws1 = Worksheets("Invoice")
Set ws2 = Worksheets("purchase")
x = 12
r = 3
Do Until x = 30
Do Until ws2.Range("A" & r).Value = ""
If ws1.Range("C" & x).Value = ws2.Range("A" & r).Value Then
newQuantity = ws2.Range("H" & r).Value - ws1.Range("E" & x).Value
ws2.Range("H" & r).Value = newQuantity
newQuant = ws2.Range("I" & r).Value + ws1.Range("E" & x).Value
ws2.Range("I" & r).Value = newQuant
x = x + 1
Else
r = r + 1
End If
Loop
x = x + 1
Loop
End Sub
Please help.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top