Hi All
I'm currently working on some vba and encountering a issue that I can't find a answer or solution for
I have within a workbook several tabs
The tabs in Questions are Open POs and PO Orders
My code is as follows
I want the above to take a value from cell J1 on the PO Orders, Filter Open POs on column D(Field 4), then copy that data into the PO Orders tab, using cell I4 as the equivalent of A1
The line that it keeps stopping on is this one
My error message is "Complie error: Argument not optional"
Any help would be gratefully received
TC
I'm currently working on some vba and encountering a issue that I can't find a answer or solution for
I have within a workbook several tabs
The tabs in Questions are Open POs and PO Orders
My code is as follows
Code:
Sub CopyData()
Dim LR As Long, ALR As Long
Dim MSht As String, DSht As String
MSht = "Open POs"
DSht = "PO Orders"
LR = Sheets(MSht).Range("A" & Rows.Count).End(xlUp).Row
ALR = Sheets(DSht).Range("I" & Rows.Count).End(xlUp).Row + 1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'filter for dropout data
Sheets(MSht).Activate
'Cells.AutoFilter
Range.AutoFilter Field:=4, Criteria1:=Worksheets("PO Orders").Range("J1").Value
Range("A2:G" & LR).SpecialCells(xlCellTypeVisible).Select
Range("A2:G" & LR).Copy
Sheets(DSht).Activate
Cells(ALR, 1).Activate
ActiveSheet.Paste
Sheets(MSht).Activate
Cells.AutoFilter
Sheets(DSht).Select
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
I want the above to take a value from cell J1 on the PO Orders, Filter Open POs on column D(Field 4), then copy that data into the PO Orders tab, using cell I4 as the equivalent of A1
The line that it keeps stopping on is this one
Code:
Range.AutoFilter Field:=4, Criteria1:=Worksheets("PO Orders").Range("J1").Value
My error message is "Complie error: Argument not optional"
Any help would be gratefully received
TC