+ Reply to Thread
Results 1 to 10 of 10

Adding a new column with row text for each vstack array

Hybrid View

benoj2005 Adding a new column with row... 11-15-2024, 05:29 AM
windknife Re: Adding a new column with... 11-15-2024, 05:37 AM
zbor Re: Adding a new column with... 11-15-2024, 05:44 AM
benoj2005 Re: Adding a new column with... 11-15-2024, 06:06 AM
windknife Re: Adding a new column with... 11-15-2024, 06:07 AM
benoj2005 Re: Adding a new column with... 11-15-2024, 06:13 AM
windknife Re: Adding a new column with... 11-15-2024, 07:40 AM
RhiSJ Re: Adding a new column with... 11-15-2024, 07:54 AM
AliGW Re: Adding a new column with... 11-15-2024, 06:31 AM
benoj2005 Re: Adding a new column with... 11-15-2024, 08:03 AM
  1. #1
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Adding a new column with row text for each vstack array

    Hopefully a nice an easy one but I'm not sure what the right approach is to add a new column to vstacks that dosen't exist in the source data and then to add row text to this new column to show the source of each vstack array.

    Simple example in the attached where I've done column I manually

    Thankyou

  2. #2
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,897

    Re: Adding a new column with row text for each vstack array

    One Way,
    =VSTACK({"Area","Sales","Extra field to show source"},HSTACK(ExpData1,IF(ExpData1[Area]<>"","ExpData1")),HSTACK(ExpData2,IF(ExpData2[Area]<>"","ExpData2")))

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Adding a new column with row text for each vstack array

    Or add one more column with Table name:
    Never use Merged Cells in Excel

  4. #4
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Re: Adding a new column with row text for each vstack array

    Perfect thanks windknife.

    Trying to avoid adding a manual helper column to all the real source data but good idea zbor

  5. #5
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,897

    Re: Adding a new column with row text for each vstack array

    You are welcome.

  6. #6
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Re: Adding a new column with row text for each vstack array

    is it possible to take the existing header array and add on a manual field rather than listing out all the headers manually? Tables 24 columns in reality to just trying to work out if theres a syntax to do this

  7. #7
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,897

    Re: Adding a new column with row text for each vstack array

    Try this,
    =VSTACK(HSTACK(ExpData1[#Headers],"Extra field to show source"),HSTACK(ExpData1,IF(ExpData1[Area]<>"","ExpData1")),HSTACK(ExpData2,IF(ExpData2[Area]<>"","ExpData2")))
    Last edited by windknife; 11-15-2024 at 08:04 AM.

  8. #8
    Forum Contributor
    Join Date
    11-01-2024
    Location
    Korea
    MS-Off Ver
    M365 64bit v2411
    Posts
    254

    Re: Adding a new column with row text for each vstack array

    Try this formula,
    it would expand extra 1 column with table name on the right, and VSTACK 2 expanded tables.

    =LET(
    AA, EXPAND(TableA,, COLUMNS(TableA)+1, OFFSET(TableA[#Headers],-1,0,1,1)),
    BB, EXPAND(TableB,, COLUMNS(TableB)+1, OFFSET(TableB[#Headers],-1,0,1,1)),
    VSTACK(HSTACK(TableA[#Headers],"Source"), AA,BB) )

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,492

    Re: Adding a new column with row text for each vstack array

    Remove the solved tag if you need further assistance.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  10. #10
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Re: Adding a new column with row text for each vstack array

    thanks both

+ 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. [SOLVED] VSTACK all ranges in Spill array
    By Andrew-Mark in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-10-2023, 07:26 AM
  2. [SOLVED] feed single array via VSTACK and REDUCE issue
    By guillaume0314 in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 09-16-2023, 08:25 AM
  3. VSTACK results of indirect references from an array
    By tdarenkov in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-16-2023, 04:11 AM
  4. [SOLVED] Adding column to an array
    By ChipsSlave in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2017, 05:22 AM
  5. Replies: 5
    Last Post: 11-24-2015, 08:15 AM
  6. Change date into text if <today and adding text if cell isblank... into an Array.
    By JasonNeedsHelp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-29-2013, 12:06 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