advanced filter than copy and paste

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
391
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
8,737
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
391
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,081,680
Messages
5,360,503
Members
400,590
Latest member
Mikealphatangoc

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top