advanced filter than copy and paste

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
414
ok i ran into something odd....so far when i do an advnaced filter via vba and then copy and pasted the filtered data....by default the code would only copy the visible cells even though i have the code written as

range("a2:p" & finalrow).copy

that is, even the the first row of filtered rate is on, say, row 10, it's copied and pasted probably by not copying starting from row 2.


but, using another file today and using similar code, it did copy all cells ...why is that?
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
9,780
Office Version
2007
Platform
Windows
You can put here your code to see when you get the finalrow, before or after filtering.


How to filter in the same place or copy to another location.
 

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
414
something like this..
Code:
finalrow = cells(rows.count,"A").end(xlup).row

range("a1:z" & finalrow).advancedfilter xlfilterinplace, criterarange:=range("caput_filter")



finalrow = cells(rows.count,"A").end(xlup).row

range("a2:z" & finalrow).copy thisworkbook.sheets("exclusions").range("a1")
in this case, it seems to cut all the data from a2 to the last row of Z, not just the visible cells after the filter.

but i have seen cases where the code does copy the visible cells only without using SpecialCells(xlCellTypeVisible), which I never bothered using because the code was working fine without it.
 
Last edited:

Forum statistics

Threads
1,086,222
Messages
5,388,552
Members
402,122
Latest member
khairalm

Some videos you may like

This Week's Hot Topics

Top