advanced filter than copy and paste

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
755
Office Version
  1. 365
  2. 2010
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?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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.
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top