trying to learn excel vba to help me with my job. I am creating a list of a dynamic inventory of parts. I could have the same part number listed several times in my inventory, on different rows for various reasons including different quantity. I want to sum quantities of each part on another sheet, providing a "Stats" sheet to give quick look at the inventory.
That being said, different part numbers will flow into and out of the inventory continuously. I am trying to code the stats page to show only part numbers that are in inventory and sums, rather than all part numbers and a bunch of zeros.
So far I have only tried to initialize the list of part numbers on the Stats sheet. Once I have that finished I will start working on summing the quantities. The top two rows are text, titles and headings.
Private Sub RefreshStatsButton_Click()
Dim FirstRowInventory As Integer
Dim LastRowInventory As Integer
Dim FirstRowStats As Integer
Dim PartNoIndexCount As Integer
Dim PartNoCol As Integer
FirstRowInventory = 3
FirstRowStats = 3
PartNoIndexCount = 3
PartNoCol = 1
LastRowInventory = Worksheets("Inventory").UsedRange.Rows.Count
For i = FirstRowInventory To LastRowInventory
If Worksheets("Inventory").Cells(i, PartNoCol).Value <> Worksheets("Inventory").Cells(PartNoIndexCount - 1, PartNoCol).Value Then
Worksheets("Inventory").Cells(i, PartNoCol).Value.Copy
Destination:=Worksheets("Stats").Cells(PartNoIndexCount, PartNoCol)
'MsgBox ("InventoryCell: " & Worksheets("Inventory").Cells(i, PartNoCol).Value & " StatsCell: " & Worksheets("Stats").Cells(PartNoIndexCount, PartNoCol))
PartNoIndexCount = PartNoIndexCount + 1
Else:
End If
Next
End Sub
I expected to get a list of each part number in inventory sheet without repeats. I get
Runtime Error 424 Object Required.
I then tried adding a Msg box to help debug (commented out) but didn't get any results. Thanks for your help!