Appreciate anyone's help creating the VBA code to execute a copy and paste function base upon certain criteria being selected. I think it needs to be a VBA script because I have a macro to clear the data in the New PO's tab once an "order" is written and the information is copied to the PO's tab. I currently have a copy and paste script which works perfect and copies 3 cells from the New PO tab to the POs tab, see below script. This is being executed by a button to "Copy the Data".
I am now looking for a VBA script which will filter/validate the quantity (column S) Column Z and extended cost from the NEW PO tab based on the category selected in Column G and paste that to the PO's tab under the correct month the order is being written, which is determined by the start date in cell T12 on the New PO tab. The additional challenge is that when the category changes for example from 00 to 01, it should drop to the next row on the PO's tab and change category as well.
Here are screen shots of the two tabs in discussion and again appreciate any insight into how to make this work.
EDITED 6/7
Sub Copy_Data() Dim Count, Qty As Long Dim CatRng, MonthRng, SDate, CxlDate, PoNumb, Vendor As Range Dim Total As Currency Dim StrTarget As String Dim Row, PORow, Col As Integer Set CatRng = Sheets("NEW PO").Range("G20:G43") Set MonthRng = Sheets("POs").Range("L122:W122") StrTarget = Sheets("New PO").Range("V12") Set SDate = Sheets("New PO").Range("T12") Set CxlDate = Sheets("New PO").Range("T13") Set PoNumb = Sheets("New PO").Range("N10") Set Vendor = Sheets("New PO").Range("D14") Count = 0 For Count = 0 To 99 Total = 0 Qty = 0 'So that the values reset each time the cat changes For Each cell In CatRng 'To get the row number then total the required information If cell.Value = Count Then Row = cell.Row Qty = Qty + Sheets("NEW PO").Range("S" & Row).Value Total = Total + Sheets("NEW PO").Range("Z" & Row).Value 'I guessed ext cost only as it has been totaled at the bottom, 'this is easily changed though End If Next cell 'Now put the totals into a PO only if there is a quantity of items If Qty > 0 Then PORow = Sheets("POs").Range("K1048576").End(xlUp).Row + 1 'I'll let you sort the PO number and other fields out but the main 3 are done below With Sheets("POs") .Range("I" & PORow).Value = Qty .Range("K" & PORow).Value = Count .Range("C" & PORow).Value = SDate .Range("D" & PORow).Value = CxlDate .Range("B" & PORow).Value = PoNumb .Range("F" & PORow).Value = Vendor 'My understanding here is that the target month in T12 is in the same format as 'the anticipated Receipt month, I hope this is what you were looking for For Each cell In MonthRng If cell.Value = StrTarget Then Col = cell.Column .Cells(PORow, Col).Value = Total 'Used .cells here as both column and row are now integers '(only way i can ever get it to work) End If Next cell End With End If Next Count End Sub