+ Reply to Thread
Results 1 to 2 of 2

Capture only displayed rows from filter for copy paste to another sheet

  1. #1
    Registered User
    Join Date
    12-01-2017
    Location
    New Jersey
    MS-Off Ver
    2016
    Posts
    63

    Capture only displayed rows from filter for copy paste to another sheet

    The code right below works as designed, however I now need to filter the "Set x = ThisWorkbook.Worksheets("AX_Data")" in the code below (Sub CopyAX()) before copying. When I add the lower code to set filters on the sheet, the variable "LastRow = x.Cells.SpecialCells(xlCellTypeLastCell).Row" still counts all rows and copies everything and not just what is visible. See filter below. I added the code above the Dim and it filtered correctly but the row count was all and not the filtered amount and all data was copied. How do I adjust the variable or restate the syntax to only copy the filtered rows displayed?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Capture only displayed rows from filter for copy paste to another sheet

    You need to use the SpecialCells function to get only visible cells.
    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

+ 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. Filter -> copy-paste to new sheet -> last row problem
    By dunnobe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-19-2018, 10:39 AM
  2. Copy paste filter values to another sheet
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-09-2018, 03:19 AM
  3. VBA to filter, copy and paste in new sheet
    By saravanan1981 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-23-2016, 10:01 PM
  4. Filter and Copy & Paste it to te last row of the other sheet
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2013, 09:56 AM
  5. VB code to filter copy and paste in a different sheet
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2013, 12:53 AM
  6. [SOLVED] filter, copy and paste from one sheet to another within a workbook
    By CharlieZangel in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-27-2013, 01:24 PM
  7. Filter records, paste into a different sheet, delete rows from original sheet.
    By gloworm1973 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2009, 05:24 AM

Tags for this Thread

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