I am building a template that has three procedure worksheets(FTP, ATP, CS) and a Failure Report worksheet. What I am attempting to do is apply an advanced filter to each of those procedure sheets, copy only the filtered results, and paste them in succession in a named range on the Failure Report.
I have the advanced filter working properly, however it causes issues when I attempt to copy the results into the Failure Report. The FTP results will paste correctly, however the ATP and CS will paste to the bottom of the named range (and expand the range). I need to tell it to paste in the next empty cell in Column A (within the named range). I have attached a copy of the results that are returned.
Sub AdvancedFilterCopyAttempt()
' Script to apply an advanced filter to multiple worksheets and copy those results to copy to the Failure Report.
'Declare Variables
Dim rngCopy As Range, rngCopyNotes As Range
Dim NextRow As Long
Dim wsFTP As Worksheet, wsATP As Worksheet, wsFail As Worksheet, wsCS As Worksheet
Set wsFTP = Sheets("Results")
Set wsATP = Sheets("ATP Results")
Set wsFail = Sheets("Failure Report")
Set wsCS = Sheets("CS Results")
Sheets("Results").Activate
Range("Results").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=Range("Criteria"), Unique:=False
Sheets("ATP Results").Activate
Range("A:I").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=Range("APTCriteria"), Unique:=True
Sheets("CS Results").Activate
Range("A:I").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=Range("CSCriteria"), Unique:=True
wsFTP.Activate
'copy FTP results to Failure Report
Set rngCopy = wsFTP.Range("Results_Part1").SpecialCells(xlCellTypeVisible)
Set rngCopyNotes = wsFTP.Range("Results_Part2").SpecialCells(xlCellTypeVisible)
Sheets("Failure Report").Range("A:A").ClearContents
NextRow = wsFail.Range("Fail_Report_Table").Cells(1, 1).Row
rngCopy.Copy wsFail.Range("A" & NextRow)
rngCopyNotes.Copy wsFail.Range("H" & NextRow)
wsATP.Activate
'copy ATP results to Failure Report
Set rngCopy = wsATP.Range("APTResults1").SpecialCells(xlCellTypeVisible)
Set rngCopyNotes = wsATP.Range("APTResults2").SpecialCells(xlCellTypeVisible)
NextRow = wsFail.Range("Fail_Report_Table").Cells(1, 1).End(xlDown).Offset(1).Row
rngCopy.Copy wsFail.Range("A" & NextRow)
rngCopyNotes.Copy wsFail.Range("H" & NextRow)
wsCS.Activate
Set rngCopy = wsCS.Range("CSResults1").SpecialCells(xlCellTypeVisible)
Set rngCopyNotes = wsCS.Range("CSResults2").SpecialCells(xlCellTypeVisible)
NextRow = wsFail.Range("Fail_Report_Table").Cells(1, 1).End(xlDown).Offset(1).Row
rngCopy.Copy wsFail.Range("A" & NextRow)
rngCopyNotes.Copy wsFail.Range("H" & NextRow)
Sheets("Failure Report").Activate
End Sub
Fail_Report_Table
always begin at row 21? If its another row, what is it? – Scott Holtzman