Hello! I have a "Ship" button with a macro that copies filled out rows in an order form and adds them to a list of shipments in another workbook.
In Workbook A, there is a table of part numbers and their quantities, referred to in the code as iRow. Sometimes I have to make partial shipments, so I will fill out the order form to have a quantity of "0" on the part numbers that will not be shipped in that particular order.
I would like to create a macro that senses if there is a quantity of 0, that specific iRow does not get transferred to the shipments list.
The shipments list is referred to as kRow in the macro. Below you can see the code.
Any help would be greatly appreciated
In Workbook A, there is a table of part numbers and their quantities, referred to in the code as iRow. Sometimes I have to make partial shipments, so I will fill out the order form to have a quantity of "0" on the part numbers that will not be shipped in that particular order.
I would like to create a macro that senses if there is a quantity of 0, that specific iRow does not get transferred to the shipments list.
The shipments list is referred to as kRow in the macro. Below you can see the code.
Code:
[COLOR=#008000]'This section copies the necessary information from Order Overview to Shipments List[/COLOR]
Sheets("Order Form").Activate
OrderNo = Range("B2").Value
Dim PartNo(100) As String
Dim Quantity(100) As Integer
Dim iRow As Integer
iRow = 8 [COLOR=#008000]'start one row early or it will skip the first row of the order[/COLOR]
Do Until IsEmpty(Cells(iRow, 1))
iRow = iRow + 1
PartNo(iRow) = Cells(iRow, 1).Value
Quantity(iRow) = Cells(iRow, 5).Value
Loop
maxRow = iRow
iRow = 9 [COLOR=#008000]'added this line to stop error of adding extra empty row[/COLOR]
[COLOR=#008000]'opens up the ship list[/COLOR]
Workbooks.Open Filename:= _
"C:\Users\Z645352\Desktop\Test1\WorkbookB.xlsm"
[COLOR=#008000]
'naming a kRow [/COLOR]
With Sheets("Shipments")
kRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1 [COLOR=#008000]'finds first empty row so that the code will not continue to rewrite in the same row over and over again[/COLOR]
End With
Do Until iRow = maxRow
[COLOR=#ff0000]'-------I was thinking to insert the If statement here, but didn't really know how to do it for iRows and kRows-------------[/COLOR]
Cells(kRow, 1).Value = PartNo(iRow)
Cells(kRow, 4).Value = Quantity(iRow)
Cells(kRow, 3).Value = Filenm
Cells(kRow, 2).Select 'add a hyperlink to the cell where the ShipNo appears
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="C:\Users\Z645352\Desktop\Test1\ShippingDoc\" & Filenm & "2018" & ShipNo & ".xlsm", TextToDisplay:=Filenm & "2018" & ShipNo
iRow = iRow + 1
kRow = kRow + 1
Loop
ActiveWorkbook.Save
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub