Run-time error '1004' The extract range has a missing or invalid field name

92 Views Asked by At
.Range("A2:Q" & LastRow).AdvancedFilter xlFilterCopy, CriteriaRange:=.Range("s2:s3"), CopyToRange:=.Range("AA2:AJ2"), Unique:=True

Who can help me out?

I've been trying to figure it out, but can not fix it.

This is the code:

Sub InventoryAdj_LoadItems()

With InvWkSht If .Range("b2").Value = True Then If MsgBox("Changes have been made to this adjustment. Are you sure you wnat to clear these changes without saving?", vbYesNo, "Changes Not Saved") = vbNo Then Exit Sub End If Application.ScreenUpdating = False .Range("A7:O9999").ClearContents 'Clear All existing data 'Remove Existing Pictures For Each PicShp In .Shapes If InStr(PicShp.Name, "ItemPic") > 0 Then PicShp.Delete 'Delete picture shape Next PicShp SortCol = .Range("B1").Value 'Set Sort Column End With

With Items LastRow = .Range("A9999").End(xlUp).Row 'Last Row If LastRow < 3 Then GoTo Nodata .Range("A2:Q" & LastRow).AdvancedFilter xlFilterCopy, CriteriaRange:=.Range("s2:s3"), CopyToRange:=.Range("AA2:AJ2"), Unique:=True

LastResultRow = .Range("AA99999").End(xlUp).Row
If LastResultRow < 3 Then GoTo Nodata

    'Run Sort
    With .Sort
    .SortFields.Clear
    .SortFields.Add Key:=Items.Cells(3, SortCol), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal  'sort based on user entry
    .SetRange Items.Range("aa3:AJ" & LastResultRow)
    .Apply
    End With

InvWkSht.Range("a7:i" & LastResultRow + 4).Value = .Range("aa3:Ai" & LastResultRow).Value 'bring over item data InvWkSht.Range("n7:n" & LastResultRow + 4).Value = .Range("aj3:AJ" & LastResultRow).Value 'bring over item DB row End With Nodata: Application.ScreenUpdating = True

End Sub

0

There are 0 best solutions below