+ Reply to Thread
Results 1 to 18 of 18

VBA: Dynamic List from same column on multiple sheets

  1. #1
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    VBA: Dynamic List from same column on multiple sheets

    Hello,

    I am back again looking for more help.

    My question is how to create a dynamic Master list on a master sheet that just grabs all the information from the same column on multiple sheets and creates 1 master list of all the values.
    Looking for 2 solutions:
    1 - just basic pull all the data into master list excluding blank rows
    2 - same as above only sorted

    The actual excel workbook can have up to 50+ worksheets but the values will always be in the same column.
    The number of rows can also be different but never more than 1000.

    I thought this would be relatively simple but I was not able to google it. I tried some filter and indirect combinations but I could not get these to work for me.
    This will be used primarily by someone that is not familiar with excel so hopefully nothing too complicated.

    Any help would be appreciated. TY
    Gray.
    Attached Files Attached Files
    Last edited by GrayWolf; 03-30-2022 at 09:37 AM. Reason: resolved

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Dynamic List from same column on multiple sheets

    Please try

    =FILTERXML("<x><m>"&TEXTJOIN("</m><m>",,Vehicles1:End!B2:B90)&"</m></x>","//m")

    insert new sheet of Vehicles# before sheet end
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: Dynamic List from same column on multiple sheets

    WOW, thank you very much. This works perfectly.
    Could I ask you to explain the formula for me? I am not sure what is going on here.

    Thank you again for the solution.
    Gray
    Last edited by AliGW; 03-30-2022 at 11:49 AM. Reason: PLEASE don't quote unnecessarily!

  4. #4
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: Dynamic List from same column on multiple sheets

    On second look. I noticed something. it does not remove duplicates, which could be an issue.
    Also is there a way to get the filter to sort if need be.

  5. #5
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Dynamic List from same column on multiple sheets

    yes, you can adapt Bo_Ry's approach to filter out dupes, and sort

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: Dynamic List from same column on multiple sheets

    ha ha ha .. I was just fooling with the formula and I discovered the exact same thing ... UNIQUE and SORT.

    Now I just need to figure out what that FILTERXLM function is doing in my example. I do not understand it at all.
    TY very much.

    Gray
    Last edited by AliGW; 03-30-2022 at 11:49 AM. Reason: PLEASE don't quote unnecessarily!

  7. #7
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Dynamic List from same column on multiple sheets

    so,

    1. the TEXTJOIN inserts </m><m> between each cell value in your range - so, assume A1:A3 holds apple, banana and carrot

    TEXTJOIN("</m><m>",,A1:A3)

    would generate

    apple</m><m>banana</m><m>carrot

    to make this a valid XML string we must bookend with open / close tags, so

    <x><m>apple.....carrot</m></x>

    the <x></x> is required as there must be a top parent node - i.e. the "m" elements are children of "x"

    2. now we have a valid XML string we can pass an xpath criteria (via 2nd parameter in FILTERXML) to extract certain elements from the string, e.g

    =FILTERXML(...,"//m")

    so retrieve all m elements irrespective of parent / level in the XML string

    the XPATH pieces can get quite convoluted depending on requirements

    HTH

  8. #8
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: Dynamic List from same column on multiple sheets

    Thank you, yes that helps immensely. I understand XML I was just not sure what the <x><m> were .. but I am imagining that you can call those whatever you like.

    I appreciate your time.
    Thank you very much to your both for the formula and the explanation.
    You've both been rep'd.

    Gray.
    Last edited by AliGW; 03-30-2022 at 11:48 AM. Reason: PLEASE don't quote unnecessarily!

  9. #9
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: Dynamic List from same column on multiple sheets

    Update:
    In the end this did not help me. The number of sheets I need to reference along with the amount of rows brings the character length too high for excel to complete the formula. After the 2 sheet the calculation stops.

    Looking for an alternative now.
    Gray.

    Added another Excel to this to show that it doesn't work after the 32,767 characters is reached
    Just take Tab 6 and slide it after END and back
    Attached Files Attached Files
    Last edited by GrayWolf; 03-30-2022 at 10:21 AM.

  10. #10
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Dynamic List from same column on multiple sheets

    For Excel Insider try

    =LET(z,VSTACK(Vehicles1:End!B2:B100000),SORT(UNIQUE(FILTER(z,z<>""))))

    or Power Query
    Change file path in red

    Please Login or Register  to view this content.
    Watch this for Power Query
    https://youtu.be/KfuYxBDBkAo
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: Dynamic List from same column on multiple sheets

    WOW .. amazing again.
    How do you come up with these things. Thank you so much.

    Are you able to explain what this formula is doing?
    1) the formula in the workbook looks a little different.
    yours - =LET(z,VSTACK(Vehicles1:End!B2:B100000),SORT(UNIQUE(FILTER(z,z<>""))))
    WrkBk - =LET(z,_xlfn.VSTACK(Vehicles1:End!B2:B100000),SORT(UNIQUE(FILTER(z,z<>""))))

    2) it works as is but then I try to edit it or use it elsewhere it breaks it, just copy. Name error now.

    Thank you for the Help.

    Gray
    Last edited by GrayWolf; 03-30-2022 at 11:49 AM.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,763

    Re: Dynamic List from same column on multiple sheets

    This:

    _xlfn.VSTACK

    means that you do not have the VSTACK function.

    This means that you are not on the insider channel.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  13. #13
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: Dynamic List from same column on multiple sheets

    Thank you for that. Looks like I am back to the drawing board. Power Pivot will not be helpful. I am not familiar nor have I ever used it and neither has the user.
    Was looking for something a little simpler.

    Might close this thread and post a question in the VBA thread and see if a macro might make more sense.

    Thank you all.
    Gray
    Last edited by AliGW; 03-30-2022 at 11:59 AM. Reason: PLEASE don't quote unnecessarily!

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,763

    Re: Dynamic List from same column on multiple sheets

    No - you don't need to do that. I can move the thread for you.

    Please stop quoting unnecessarily!

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,763

    Re: VBA: Dynamic List from same column on multiple sheets

    The thread has been moved and its title tweaked.

  16. #16
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: VBA: Dynamic List from same column on multiple sheets

    Thank you very much

    Gray

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,188

    Re: VBA: Dynamic List from same column on multiple sheets

    Please Login or Register  to view this content.
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  18. #18
    Registered User
    Join Date
    09-09-2021
    Location
    London, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    56

    Re: VBA: Dynamic List from same column on multiple sheets

    Hi John,

    Thank you for this code.
    I have tested this on the actual workbook and it seems to do exactly what I need.

    There was 1 more question. Some of the values are not just a number v1234 for example, this shows up fine, but there are occasional days where an actual number value 987 (number) may populate as 987 (text) number. I have noticed that your VBA list this as a separate value.
    Is there a way, in the loop, to convert the text 987 to a number but still leave v1234 as a legit unique value?

    I messed with a quick excel formula to do [cell]+1 but that gives a #value error on the v1234 numbers so that was a bust.
    I have added some comments to the code, since it will be another user will be relying on this code going forward and I want to make sure they understand what is going on.
    Can you confirm if my comments are accurate?

    Thank you very much. Once you respond I'll mark this as solved.

    Commented Code:
    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. Create a dynamic list from multiple sheets
    By shbiskup in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-28-2022, 04:04 AM
  2. [SOLVED] Consolidating names from multiple sheets to create one dynamic list
    By Rick Rick in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-10-2021, 12:51 PM
  3. Replies: 2
    Last Post: 09-17-2020, 05:17 AM
  4. [SOLVED] Dynamic ordered list, pulling from multiple sheets
    By ostie in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-21-2019, 04:11 PM
  5. Replies: 1
    Last Post: 01-31-2017, 06:32 PM
  6. How to combine dynamic ranges from multiple sheets into one list?
    By mst3k in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-07-2015, 03:25 AM
  7. Multiple Column Dynamic Dependent List
    By wsublet86 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-18-2014, 03:25 PM

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