+ Reply to Thread
Results 1 to 13 of 13

using range.advancedfilter to copy data into a list object

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    using range.advancedfilter to copy data into a list object

    Good morning, all.

    I am working with Range.AdvancedFilter to get a unique set of values FROM a listObject and then insert them INTO another list object.

    The destination listObject is created using VBA and is initially only a header and one row below that.

    I can use the code below to get a unique set of values FROM Categories[Agency] but when i copy them TO totalPaidToAgency[Agency] only the first element in the range is inserted into totalPaidToAgency. The others are there but are not part of totalPaidToAgency. How can I use AdvancedFilter with xlFilterCopy to insert all of the elements into totalPaidToAgency?

    Thank you in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: using range.advancedfilter to copy data into a list object

    Why not create the 2nd listobject from the copied range from the advanced filter?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: using range.advancedfilter to copy data into a list object

    Quote Originally Posted by Norie View Post
    Why not create the 2nd listobject from the copied range from the advanced filter?
    @Norie, that is a good idea. I didnt think of it that way. I will mess around with it and see if I can get that to work

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: using range.advancedfilter to copy data into a list object

    I meant to post this with the first post but hit the Reply button to soon.

    It's a simple example of what I suggested.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: using range.advancedfilter to copy data into a list object

    This works with one exception...

    I insert my AdvancedFilter copy data at A3. A1 is a text (presentation purposes only) title of my table. A2 is my header row.

    Because I inserted my data at A3, when I use Range(A3).CurrentRegion, it pulls A1 and A2 into current region. Therefore, A1 becomes my header row instead of A2.

    Is there a way to do something like a Range.CurrentRegion + 1? That obviously doesnt work but...something like that?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: using range.advancedfilter to copy data into a list object

    Thought that might be a problem, there's a few ways to deal with it, kind of depends on the layout of the sheet.

    Could you upload a sample workbook so I can see how your worksheet is set up?
    Last edited by Norie; 05-28-2013 at 02:12 PM.

  7. #7
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: using range.advancedfilter to copy data into a list object

    Quote Originally Posted by Norie View Post
    Thought that might be a problem, there's a few ways to deal with it, kind of depends on the layout of the sheet.

    Could you upload a sample workbook so I can see how your worksheet is set up?
    Here you go. I have taken out all of the actual data because is it not something I can publish. If you need more sample data than what I have provided, please let me know.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: using range.advancedfilter to copy data into a list object

    Also, thanks again for your continued help.

  9. #9
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: using range.advancedfilter to copy data into a list object

    I have been trying to get this to work but, I am getting an error of "object required" at endRange which I am guessing means that it cant convert Rows.Count to something that can be added to a String. Sorry, I know my code lingo is out of whack here...it has been a long time since I seriously coded.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: using range.advancedfilter to copy data into a list object

    Quote Originally Posted by mtnbiker98 View Post
    I have been trying to get this to work but, I am getting an error of "object required" at endRange which I am guessing means that it cant convert Rows.Count to something that can be added to a String. Sorry, I know my code lingo is out of whack here...it has been a long time since I seriously coded.

    Please Login or Register  to view this content.

    Figured this one out. endRange is not an object so I cant use "Set"

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: using range.advancedfilter to copy data into a list object

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  12. #12
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: using range.advancedfilter to copy data into a list object

    Quote Originally Posted by Norie View Post
    Thought that might be a problem, there's a few ways to deal with it, kind of depends on the layout of the sheet.

    Could you upload a sample workbook so I can see how your worksheet is set up?

    I figured most of it out with the Code below. It builds the table with the correct headers now. However, when I pull CurrentRegion.Count I get 206 where I should get something like 103 to 105. I start the whole sub by clearing all cells with ActiveSheet.Cells.Clear so, there isnt any other data in there. Any ideas?

  13. #13
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: using range.advancedfilter to copy data into a list object

    Got it. Thanks! I will do so in the future.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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