+ Reply to Thread
Results 1 to 10 of 10

Copy filtered cells with VBA

  1. #1
    Forum Contributor
    Join Date
    04-20-2020
    Location
    New Jersey, NJ
    MS-Off Ver
    MS Office 365
    Posts
    159

    Copy filtered cells with VBA

    Trying to copy from a sheet that I manually sorted to remove all entries if column "B" has a zero. When I use this code, it pastes as if it wasn't sorted.

    Any thoughts?

    Thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    04-20-2020
    Location
    New Jersey, NJ
    MS-Off Ver
    MS Office 365
    Posts
    159

    Re: Copy filtered cells with VBA

    I changed the code to paste values
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Copy filtered cells with VBA


    Hi,

    SpecialCells is useless here as Range.Copy method copies only the visible cells !
    But here as the logic needed is not to copy but to delete the unwanted or ? …

  4. #4
    Forum Contributor
    Join Date
    04-20-2020
    Location
    New Jersey, NJ
    MS-Off Ver
    MS Office 365
    Posts
    159

    Re: Copy filtered cells with VBA

    Is there a way to delete them?

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy filtered cells with VBA

    Well, there's no filter so there won't be any zero height cells. If by Column B Having a zero you mean a null, then something like this would work:

    Please Login or Register  to view this content.
    Or else find the last row >0
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  6. #6
    Forum Contributor
    Join Date
    04-20-2020
    Location
    New Jersey, NJ
    MS-Off Ver
    MS Office 365
    Posts
    159

    Re: Copy filtered cells with VBA

    Yes, I meant the cells contain the value "0".

    Is there a way to delete the cells?

  7. #7
    Forum Contributor
    Join Date
    04-20-2020
    Location
    New Jersey, NJ
    MS-Off Ver
    MS Office 365
    Posts
    159

    Re: Copy filtered cells with VBA

    Used this code

    Please Login or Register  to view this content.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy filtered cells with VBA

    That should work. Thanks for the rep!

  9. #9
    Forum Contributor
    Join Date
    04-20-2020
    Location
    New Jersey, NJ
    MS-Off Ver
    MS Office 365
    Posts
    159

    Re: Copy filtered cells with VBA

    No prob, any thoughts as to why this code takes so long to run? It's about 15,000 lines that it looks for the zeroes in, any way to speed that up?

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy filtered cells with VBA

    Here's a filter:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 09-27-2019, 04:32 PM
  2. Copy visible cells only from filtered
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2015, 09:39 AM
  3. Copy and paste data with filtered cells
    By rikkyshh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-31-2013, 06:54 AM
  4. Copy and pasting filtered cells
    By e1504 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-11-2012, 11:56 AM
  5. VBA: copy by address filtered selection of cells
    By mottyqa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-18-2011, 03:30 PM
  6. How to copy cells to a filtered table?
    By joshuar in forum Excel - New Users/Basics
    Replies: 14
    Last Post: 07-08-2010, 06:05 AM
  7. Copy and Paste on Filtered cells
    By rlkerr in forum Excel General
    Replies: 2
    Last Post: 06-24-2009, 02:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1