MAMIBUSSOL
Board Regular
- Joined
- Jun 2, 2011
- Messages
- 95
i am running a piece of code which filters some data based on an account
I am then copying this data to another worksheet, this code does this if it has matching criteria, if the filter contains no results, it still works but it copies every piece of data.
is it possible to adjust the above code to drop out of the with statement if the filter produces NO results and not copy any data, so in essence bypass this line of code
I am then copying this data to another worksheet, this code does this if it has matching criteria, if the filter contains no results, it still works but it copies every piece of data.
Code:
With ActiveWorkbook.Worksheets("CRED")
.Range("$A$1:$IE$388").AutoFilter Field:=3, Criteria1:="=ADVERT"
.Range("$A$3:$G$388").Copy Sheets("TRIAL").Range("A" & Sheets("TRIAL").Rows.Count).End(xlUp).Offset(1)
End With
is it possible to adjust the above code to drop out of the with statement if the filter produces NO results and not copy any data, so in essence bypass this line of code
Code:
.Range("$A$3:$G$388").Copy Sheets("TRIAL").Range("A" & Sheets("TRIAL").Rows.Count).End(xlUp).Offset(1)