+ Reply to Thread
Results 1 to 19 of 19

Copy a fixed range of cells from a filtered Table

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Copy a fixed range of cells from a filtered Table

    Hi Guys,

    I Need a macro that filters my table my a certain criteria in column B, Sorts the table by descending magnitude of the field H, and then copies the top10 values of the field H. I have accomplished the first two tasks already. However, I cant select range H10:H19, since as the filters from the first column change, the first ten values could actually be in rows 25,27,34,56....etc How Can I select the range of the ten first VISIBLE rows as they appeaar after the filter? Thanks

  2. #2
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    Basically a piece of code that allows me to copy the first ten Cells below the "Nominal" Header Cell, regardless of whether they are rows 10-19 or 12,24,35,46,57,68,79...etc

  3. #3
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Copy a fixed range of cells from a filtered Table

    Hi..

    Using a UDF.. you can ascertain the First Visible Row after filtering...

    Replace the variables like "YourSheet" and "YourCriteria" etc with your own...

    Please Login or Register  to view this content.
    Use it like..

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    Oh Thanks but I cant get it to work... How could I implement it in the following code?

    Please Login or Register  to view this content.
    Last edited by jsuarez199; 06-27-2013 at 04:54 AM.

  5. #5
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Copy a fixed range of cells from a filtered Table

    Hi..

    Upload a sample Workbook and i will take a look...

  6. #6
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    here you go, Thanks!
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    TESTAA.xlsmhere you go, Thanks!

  8. #8
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    Any Luck? :S

  9. #9
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Copy a fixed range of cells from a filtered Table

    Hi..

    I got into a bit of a mess.. I think i would have been better starting form scratch instead of trying to modify your code..

    Having said that.. the part you needed ( copy top 10 rows after autofiltering table) seems to work..

    Step through the code to see how it does it..
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    OK Ill get back to you! Fingers crossed... Thanks!

  11. #11
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    It works fine for the small spreadsheet but when I transfer the code to my big one it gives me an error in the function FirstVisibleValue


    Line:Set R= Activesheet....

    Error 9 - Subscript out of range.


    Any ideas?

  12. #12
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Copy a fixed range of cells from a filtered Table

    Is the sheet where the Function needs to be applied to the actual activesheet at the time of the Function call?

    k.. not sure.. but i can replicate the same error if I don't have the exact correct Table name.. which in the case of the Sample workbook I sent is as shown below..


    Please Login or Register  to view this content.
    Last edited by apo; 06-27-2013 at 04:10 AM.

  13. #13
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    Yeah, I have a Sheets("Mysheet").Select just before the function call

  14. #14
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    In this case Sheets("F.C.SSA-View 2").Select

  15. #15
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    I have edited tyhe code above

  16. #16
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Copy a fixed range of cells from a filtered Table

    Hi..

    Can you paste the entire Function code as it appears in your Workbook...

  17. #17
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    Please Login or Register  to view this content.

  18. #18
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Copy a fixed range of cells from a filtered Table

    Hi..

    I don't know why its not working.. like you say.. it works as it should in the Test Workbook i sent..

    All i can suggest is that you upload the workbook your working on and hopefully I or someone else can find the issue..

  19. #19
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Copy a fixed range of cells from a filtered Table

    Apparently its too big to upload :S Whats the limit?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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