advanced filter than copy and paste

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
420
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?
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
10,292
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
420
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:

Watch MrExcel Video

Forum statistics

Threads
1,090,490
Messages
5,414,847
Members
403,548
Latest member
frostinheart

This Week's Hot Topics

Top