Hello
I have written code that filters and copies a range correctly EXCEPT when there is no data to copy. I've tried if count > 0 then ....but it isn't working. Below is the code that works until there isn't data to meet the criterion.
P.S. why can I not paste into posts?
I have written code that filters and copies a range correctly EXCEPT when there is no data to copy. I've tried if count > 0 then ....but it isn't working. Below is the code that works until there isn't data to meet the criterion.
Code:
Sub Chart_list()
Dim src as worksheet
Dim tgt as worksheet
Dim filterrange as range
Dim copyrange as range
Dim lastrow as long
Set src = Sheets("Chart_Listing")
Set tgt = Sheets("Chart_Export")
If tgt.range("B11:B11").value <> "" then
tgt.range("B11:H50").entirerow.delete
End If
src.autofiltermode=false
lastrow=src.range("A" & src.rows.count).end(xlup).row
set filterrange=src.range("A1:G" & lastrow)
set copyrange=src.range("A2:G" & lastrow)
filterrange.autofilter field:=1, Criteria1=tgt.range("C7:C7").value
filterrange.autofilter field:=6, Criteria1=tgt.range("M1:M1").value
copyrange.specialcells(xlcelltypevisible).copy tgt.range("B11:H100")
End Sub
P.S. why can I not paste into posts?