+ Reply to Thread
Results 1 to 8 of 8

Convert a Variable Array into a List where each Row is an Input of the Array (Tried TOCOL)

  1. #1
    Registered User
    Join Date
    07-13-2023
    Location
    CA, US
    MS-Off Ver
    2208
    Posts
    4

    Convert a Variable Array into a List where each Row is an Input of the Array (Tried TOCOL)

    Hello Everyone,

    I can do this in VBA, but this particular workbook has the requirement of being macro-free unfortunately.

    My workbook will have a grid with 7 columns that users need to input countries and numbers into. The number of rows and which cells are used/left blank is totally variable as are the number of rows input.

    This is an example of the input tab.

    Country Dom For Pass Gen Otr Ptr
    US 10 42 39 68
    FR 200
    UK 45 39 400

    This is an example of what I would need to output with formulas given the above input. The formula TOCOL makes putting the numbers into the 3rd column super easy, but I'm not sure how to return the first and second columns.

    Country Type Amount
    US Dom 10
    US For 42
    US Pass 39
    US Gen 68
    FR Ptr 200
    UK For 45
    UK Pass 39
    UK Gen 400

    I considered using INDEX and some kind of COUNTA to dynamically set the reference for the number of times any given country needs to be repeated (e.g., there's four inputs for US, so US gets repeated four times).

    I did think about trying to return the country and type first, then doing a lookup for the numbers, but the problem is, the countries can end up having more than one instance (which is a pain), so there maybe more than one instance of any given country AND code combo.

    Any help would be greatly appreciated. Thank you!

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,083

    Re: Convert a Variable Array into a List where each Row is an Input of the Array (Tried TO

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

  3. #3
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: Convert a Variable Array into a List where each Row is an Input of the Array (Tried TO

    One click in Power Query

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-13-2023
    Location
    CA, US
    MS-Off Ver
    2208
    Posts
    4

    Re: Convert a Variable Array into a List where each Row is an Input of the Array (Tried TO

    Quote Originally Posted by Fluff13 View Post
    How about
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Wow! HSTACK for the win. What a great formula. This does exactly what I wanted. Thank you so much! May I ask you how you came up with using 1/0 for the FALSE components of the IF formulas?
    I see what happens if I change that to nothing or "". It no longer makes the spilled array no longer dynamically work for empty sizes. I'm just curious where I can learn more about why it works to use the 1/0 for the false component of the IF formulas.

    Again, huge thank you for this!
    Last edited by ATaxMan; 07-13-2023 at 08:41 AM.

  5. #5
    Registered User
    Join Date
    07-13-2023
    Location
    CA, US
    MS-Off Ver
    2208
    Posts
    4

    Re: Convert a Variable Array into a List where each Row is an Input of the Array (Tried TO

    Quote Originally Posted by JEC. View Post
    One click in Power Query

    Please Login or Register  to view this content.

    Thanks for the Unpivot advice! PowerQuery is usually my first GoTo even before VBA, but in this case, it was requested that I make this workpaper not use anything that intimidates other tax accountants (like PowerQuery) - I know it's frustrating and a bit sad. Finance people are evolve over time I think.

    Thank you!
    Last edited by ATaxMan; 07-13-2023 at 08:40 AM.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,083

    Re: Convert a Variable Array into a List where each Row is an Input of the Array (Tried TO

    May I ask you how you came up with using 1/0 for the FALSE components of the IF formulas?
    It doesn't need to be 1/0 it can be anything that will cause an error. So you could use NA() or maybe x (not in quotes). The 2 as the 2nd argument in TOCOL tells the function to ignore errors

  7. #7
    Registered User
    Join Date
    07-13-2023
    Location
    CA, US
    MS-Off Ver
    2208
    Posts
    4

    Re: Convert a Variable Array into a List where each Row is an Input of the Array (Tried TO

    Quote Originally Posted by Fluff13 View Post
    It doesn't need to be 1/0 it can be anything that will cause an error. So you could use NA() or maybe x (not in quotes). The 2 as the 2nd argument in TOCOL tells the function to ignore errors
    Ah, OK, that makes a lot of sense. Thank you, once again!

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,083

    Re: Convert a Variable Array into a List where each Row is an Input of the Array (Tried TO

    You're welcome & thanks for the feedback.

+ 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: 4
    Last Post: 04-25-2017, 11:01 AM
  2. [SOLVED] Excel 2003 Array as input - how to place output in a second array?
    By theelkhunter in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-10-2013, 02:04 PM
  3. Replies: 19
    Last Post: 05-09-2012, 03:31 AM
  4. Add Items to Array and list in input box.
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-31-2011, 04:21 AM
  5. Replace hard coded array in formula with link to input array
    By David Brown in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-08-2011, 07:45 AM
  6. Replies: 2
    Last Post: 04-01-2010, 03:54 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