+ Reply to Thread
Results 1 to 11 of 11

Vba to copy last 5 visible rows from autofilter range

  1. #1
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,159

    Vba to copy last 5 visible rows from autofilter range

    Hi All

    Have been searching without results....is there a way to copy only the last 5 visible rows after a range has been filtered.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Vba to copy last 5 visible rows from autofilter range

    Hi

    Maybe this would work:

    Copy your filtered data into a known Row

    Then Select that new Data using Currentregion

    Split the current region address into an array using the Split function

    Adjust your array variables

    Copy your required data

    Deete the current region.


    Please Login or Register  to view this content.
    Last edited by mehmetcik; 08-26-2017 at 12:06 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,159

    Re: Vba to copy last 5 visible rows from autofilter range

    Thanks mehmetcik for your response...Seems lengthy...Nothing easier...
    Will give it a go...

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

    Re: Vba to copy last 5 visible rows from autofilter range

    There may be a quicker way - but after the filter:

    Please Login or Register  to view this content.
    will count the visible rows - then you can find where the count is t-5
    and copy from there
    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

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,159

    Re: Vba to copy last 5 visible rows from autofilter range

    Hi xladept
    then you can find where the count is t-5
    Just can't think straight...How to do this

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

    Re: Vba to copy last 5 visible rows from autofilter range

    Subtotal 9 is the sum 3 is the countA - so something like:

    Please Login or Register  to view this content.
    * If that doesn't work try 103 instead of 3 as 103 excludes manually hidden rows
    Last edited by xladept; 08-26-2017 at 12:13 PM.

  7. #7
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Vba to copy last 5 visible rows from autofilter range

    ...Seems lengthy...Nothing easier...
    How about an UDF, you don't even have to think

    Please Login or Register  to view this content.
    Attached Files Attached Files
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  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: Vba to copy last 5 visible rows from autofilter range

    * I forgot the special cells - so:

    Please Login or Register  to view this content.

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

    Re: Vba to copy last 5 visible rows from autofilter range

    @ - Karedog Thinking? What's that

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,159

    Re: Vba to copy last 5 visible rows from autofilter range

    @ karedog...
    Perfect, thanks...
    @ xladept...
    Works as well...

    gonna go with karedog's solution...

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Vba to copy last 5 visible rows from autofilter range

    @Orrin,
    Thinking :
    It is a process to prevent the brain from rusting.

    And if you ask "What is rusting ?"
    It is what will happened to your brain if you stop thinking.

    --------

    @sintek,
    You are welcome, don't forget to mark the thread as solved.

    Regards

+ 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: 02-11-2015, 07:47 AM
  2. [SOLVED] Userform autofilter visible rows
    By PNI001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2014, 05:04 AM
  3. [SOLVED] Defining range of visible rows after autofilter.
    By agentblue in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-11-2013, 04:43 AM
  4. Use visible rows from autofilter to build Pivot table. Or use visible rows to Copy/Paste
    By mwhitedesigns in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2012, 10:34 AM
  5. [SOLVED] Copy/Pasting Values from visible cells (using autofilter) to visible cells
    By evakotsi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2012, 07:49 AM
  6. Userform autofilter visible rows
    By willpeg in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-15-2007, 07:37 AM
  7. AutoFilter: Loop Thru Visible Rows?
    By Damian Carrillo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2005, 10:05 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