Vertically stack columns

MossyPants

New Member
Joined
May 21, 2022
Messages
23
Office Version
  1. 365
Platform
  1. Windows
I'm looking for a way to vertically combine multiple columns of different lengths into a single master column. The columns' rows may be added or deleted from them in the future. When that happens, the master column should auto-update. I used to have a LET function that performed this task, but our company's Excel has been downgraded recently, and LET (or VSTACK) are no longer available.
Here is the worksheet. I would like every Set to be consolidated into column A.
Book1.xlsx
ABCD
1All SetsSetASetBSetC
2
3JB00 Fluorescent White CottonMz-1 Baby FoodEMPA-101 Carbon black/olive oil
4JB01 Carbon on CottonMz-2 TeaEMPA-104 Carbon black/olive oil on PolyCotton
5JB02 Protein on CottonMz-3 Spagetti SauceEMPA-106 Carbon black/mineral oil
6JB03 Sebum on CottonMz-4 MakeupEMPA-107 Carbon black/olive oil on Wool
7JB04 Water Soluble DirtMz-5 ClayEMPA-111 Blood
8JB05 Clay Type Dirt ClothMz-6 Carrot JuiceEMPA-112 Cocoa
9Mz-7 ACD BloodEMPA-114 Red wine
10Mz-8 Curry sauceEMPA-115 Immedial black
11Mz-9 Anchor ButterEMPA-116 Blood/milk/ink
12Mz-10 GrassEMPA-117 Blood/milk/ink on PolyCotton
13Mz-11 Chocolate DesertEMPA-118 Sebum/pigment
14Mz-12 Red WineEMPA-119 Sebum/pigment on PolyCotton
15Mz-13 Used Engine OilEMPA-120 Grease/quartz/iron oxide
16Mz-14 Animal Fat & DyeEMPA-122 Cotton soiled with Red Wine AGED
17Mz-15 Garden PeatEMPA-123 Cotton soiled Low Temp Washing
18Mz-16 BlankEMPA-128/1 Cotton Jeans, Indigo/sulfur black soiled
19GC7-1 Heinz Banana Baby FoodEMPA-130 Cotton dyed with Direct Red 83.1
20GC7-2 Heinz Apple & Banana BFEMPA-131 Acid blue 113 on Polyamide
21GC7-3 Heinz Apple & Mango BFEMPA-132 Cotton dyed with Direct black 22
22GC7-4 Heinz Spaghetti Bolognaise BFEMPA-133 Cotton dyed with Direct blue 71
23GC7-5 Veg. & Turkey (Hipp BF)
24GC7-6 Bisto Gravy
25GC7-7 Coleman's Mustard
26GC7-8 Heinz Sun Dried Tomato Sauce
27GC7-9 Tomato Soup (Campbell's)
28GC7-10 Heinz Spaghetti Sauce
29GC7-11 HP Brown Sauce
30GC7-12 Colemans Beef Casserole
31GC7-13 Homepride Chilli Con Carne
32GC7-14 Asda Chocolate Ice Cream
33GC7-15 Frijj Chocolate Milkshake
34GC7-16 Nestle Chocolate Build Up
35GC8-1 Gerber Banana BF
36GC8-2 Gerber Apple & Banana BF (Mixed Cereal)
37GC8-3 Gerber Apple Cinnamon Oatmeal BF
38GC8-4 Gerber Banana Raspberry Oatmeal BF
39GC8-5 Quaker Original Oatmeal
40GC8-6 Quaker Apples & Cinnamon Oatmeal
41GC8-7 Quaker Cinnamon Spice Oatmeal
42GC8-8 Quaker Maple & Brown Sugar Oatmeal
43GC8-9 Gerber Sweet Potato BF
StainList
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Excel has been downgraded recently, and LET (or VSTACK) are no longer available.
How would we know what functions are available?
Have you gone back to Excel 2019 or some other particular version?
Are you able to use any dynamic array formulas that automatically 'spill' into the required rows/columns?
 
Upvote 0
How would we know what functions are available?
Have you gone back to Excel 2019 or some other particular version?
Are you able to use any dynamic array formulas that automatically 'spill' into the required rows/columns?
It's still Excel 365, but I believe now we're on semi-annual enterprise channel, instead of current channel. No admin privileges, either, so I cannot switch channels.
I am not sure what formulas are or aren't available. I just know that my LET and VSTACK formulas stopped working after our system "upgrade".
 
Upvote 0
It's still Excel 365
OK, in that case you could try this (adjust row 50 if required) in A3 unless your data columns are actually much longer than your samples in which case the formula may return an error.

Excel Formula:
=SUBSTITUTE(FILTERXML("<p><c>"&SUBSTITUTE(TEXTJOIN("</c><c>",1,B3:B50,C3:C50,D3:D50),"&","#")&"</c></p>","//c"),"#","&")
 
Upvote 0
OK, in that case you could try this (adjust row 50 if required) in A3 unless your data columns are actually much longer than your samples in which case the formula may return an error.

Excel Formula:
=SUBSTITUTE(FILTERXML("<p><c>"&SUBSTITUTE(TEXTJOIN("</c><c>",1,B3:B50,C3:C50,D3:D50),"&","#")&"</c></p>","//c"),"#","&")
Wow, what a neat way of doing this! It worked...until one of my data cells happened to contain a ">" symbol. Any work-around?
 
Upvote 0
.until one of my data cells happened to contain a ">" symbol
That probably means that you also had one or more with a "<" symbol. You could try this version but if any more 'difficult' characters appear then it would probably be best to look for an alternative method.

Excel Formula:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(FILTERXML("<p><c>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXTJOIN("^",1,B3:B50,C3:C50,D3:D50),"&","#"),"<","!"),">","@"),"^","</c><c>")&"</c></p>","//c"),"#","&"),"!","<"),"@",">")
 
Upvote 0
if any more 'difficult' characters appear then it would probably be best to look for an alternative method.
.. vba would be one such method.
However, another formula method that is not so sensitive to what characters are in your data would be this - but ..
  • It does require to be copied down as far as might ever be needed, and
  • Assumes that there are no formulas returning "" in columns B:D (though an adjustment could be made for that if required)
This formula would go in A3:
Excel Formula:
=IFERROR(INDEX(B:B,AGGREGATE(15,6,ROW(B$3:B$50)/(B$3:B$50<>""),ROWS(A$3:A3))),
IFERROR(INDEX(C:C,AGGREGATE(15,6,ROW(B$3:B$50)/(C$3:C$50<>""),ROWS(A$3:A3)-COUNTA(B$3:B$50))),
IFERROR(INDEX(D:D,AGGREGATE(15,6,ROW(B$3:B$50)/(D$3:D$50<>""),ROWS(A$3:A3)-COUNTA(B$3:C$50))),"")))
 
Upvote 0
Use power query and option to
1665991397139.png

Delete the Attribute column and load complete list back to column A
1665991468867.png




ValueSetASetBSetC
JB00 Fluorescent White CottonJB00 Fluorescent White CottonMz-1 Baby FoodEMPA-101 Carbon black/olive oil
Mz-1 Baby FoodJB01 Carbon on CottonMz-2 TeaEMPA-104 Carbon black/olive oil on PolyCotton
EMPA-101 Carbon black/olive oilJB02 Protein on CottonMz-3 Spagetti SauceEMPA-106 Carbon black/mineral oil
JB01 Carbon on CottonJB03 Sebum on CottonMz-4 MakeupEMPA-107 Carbon black/olive oil on Wool
Mz-2 TeaJB04 Water Soluble DirtMz-5 ClayEMPA-111 Blood
EMPA-104 Carbon black/olive oil on PolyCottonJB05 Clay Type Dirt ClothMz-6 Carrot JuiceEMPA-112 Cocoa
JB02 Protein on Cottonnew item 1Mz-7 ACD BloodEMPA-114 Red wine
Mz-3 Spagetti Saucenew item1/2Mz-8 Curry sauceEMPA-115 Immedial black
EMPA-106 Carbon black/mineral oilMz-9 Anchor ButterEMPA-116 Blood/milk/ink
JB03 Sebum on CottonMz-10 GrassEMPA-117 Blood/milk/ink on PolyCotton
Mz-4 MakeupMz-11 Chocolate DesertEMPA-118 Sebum/pigment
EMPA-107 Carbon black/olive oil on WoolMz-12 Red WineEMPA-119 Sebum/pigment on PolyCotton
JB04 Water Soluble DirtMz-13 Used Engine OilEMPA-120 Grease/quartz/iron oxide
Mz-5 ClayMz-14 Animal Fat & DyeEMPA-122 Cotton soiled with Red Wine AGED
EMPA-111 BloodMz-15 Garden PeatEMPA-123 Cotton soiled Low Temp Washing
JB05 Clay Type Dirt ClothMz-16 BlankEMPA-128/1 Cotton Jeans, Indigo/sulfur black soiled
Mz-6 Carrot JuiceGC7-1 Heinz Banana Baby FoodEMPA-130 Cotton dyed with Direct Red 83.1
EMPA-112 CocoaGC7-2 Heinz Apple & Banana BFEMPA-131 Acid blue 113 on Polyamide
new item 1GC7-3 Heinz Apple & Mango BFEMPA-132 Cotton dyed with Direct black 22
Mz-7 ACD BloodGC7-4 Heinz Spaghetti Bolognaise BFEMPA-133 Cotton dyed with Direct blue 71
EMPA-114 Red wineGC7-5 Veg. & Turkey (Hipp BF)new item3
new item1/2GC7-6 Bisto Gravy
Mz-8 Curry sauceGC7-7 Coleman's Mustard
EMPA-115 Immedial blackGC7-8 Heinz Sun Dried Tomato Sauce
Mz-9 Anchor ButterGC7-9 Tomato Soup (Campbell's)
EMPA-116 Blood/milk/inkGC7-10 Heinz Spaghetti Sauce
Mz-10 GrassGC7-11 HP Brown Sauce
EMPA-117 Blood/milk/ink on PolyCottonGC7-12 Colemans Beef Casserole
Mz-11 Chocolate DesertGC7-13 Homepride Chilli Con Carne
EMPA-118 Sebum/pigmentGC7-14 Asda Chocolate Ice Cream
Mz-12 Red WineGC7-15 Frijj Chocolate Milkshake
EMPA-119 Sebum/pigment on PolyCottonGC7-16 Nestle Chocolate Build Up
Mz-13 Used Engine OilGC8-1 Gerber Banana BF
EMPA-120 Grease/quartz/iron oxideGC8-2 Gerber Apple & Banana BF (Mixed Cereal)
Mz-14 Animal Fat & DyeGC8-3 Gerber Apple Cinnamon Oatmeal BF
EMPA-122 Cotton soiled with Red Wine AGEDGC8-4 Gerber Banana Raspberry Oatmeal BF
Mz-15 Garden PeatGC8-5 Quaker Original Oatmeal
EMPA-123 Cotton soiled Low Temp Washing<GC8-6 Quaker Apples & Cinnamon Oatmeal
Mz-16 BlankGC8-7 Quaker Cinnamon Spice Oatmeal
EMPA-128/1 Cotton Jeans, Indigo/sulfur black soiledGC8-8 Quaker Maple & Brown Sugar Oatmeal
GC7-1 Heinz Banana Baby Food>GC8-9 Gerber Sweet Potato BF
EMPA-130 Cotton dyed with Direct Red 83.1New item
GC7-2 Heinz Apple & Banana BFnew item2
EMPA-131 Acid blue 113 on Polyamide
GC7-3 Heinz Apple & Mango BF
EMPA-132 Cotton dyed with Direct black 22
GC7-4 Heinz Spaghetti Bolognaise BF
EMPA-133 Cotton dyed with Direct blue 71
GC7-5 Veg. & Turkey (Hipp BF)
new item3
GC7-6 Bisto Gravy
GC7-7 Coleman's Mustard
GC7-8 Heinz Sun Dried Tomato Sauce
GC7-9 Tomato Soup (Campbell's)
GC7-10 Heinz Spaghetti Sauce
GC7-11 HP Brown Sauce
GC7-12 Colemans Beef Casserole
GC7-13 Homepride Chilli Con Carne
GC7-14 Asda Chocolate Ice Cream
GC7-15 Frijj Chocolate Milkshake
GC7-16 Nestle Chocolate Build Up
GC8-1 Gerber Banana BF
GC8-2 Gerber Apple & Banana BF (Mixed Cereal)
GC8-3 Gerber Apple Cinnamon Oatmeal BF
GC8-4 Gerber Banana Raspberry Oatmeal BF
GC8-5 Quaker Original Oatmeal
<GC8-6 Quaker Apples & Cinnamon Oatmeal
GC8-7 Quaker Cinnamon Spice Oatmeal
GC8-8 Quaker Maple & Brown Sugar Oatmeal
>GC8-9 Gerber Sweet Potato BF
New item
new item2
 
Last edited:
Upvote 0
That probably means that you also had one or more with a "<" symbol. You could try this version but if any more 'difficult' characters appear then it would probably be best to look for an alternative method.

Excel Formula:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(FILTERXML("<p><c>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXTJOIN("^",1,B3:B50,C3:C50,D3:D50),"&","#"),"<","!"),">","@"),"^","</c><c>")&"</c></p>","//c"),"#","&"),"!","<"),"@",">")
Yes, more difficult characters were encountered, unfortunately. That column is a few thousand items long 😅
.. vba would be one such method.
However, another formula method that is not so sensitive to what characters are in your data would be this - but ..
  • It does require to be copied down as far as might ever be needed, and
  • Assumes that there are no formulas returning "" in columns B:D (though an adjustment could be made for that if required)
This formula would go in A3:
Excel Formula:
=IFERROR(INDEX(B:B,AGGREGATE(15,6,ROW(B$3:B$50)/(B$3:B$50<>""),ROWS(A$3:A3))),
IFERROR(INDEX(C:C,AGGREGATE(15,6,ROW(B$3:B$50)/(C$3:C$50<>""),ROWS(A$3:A3)-COUNTA(B$3:B$50))),
IFERROR(INDEX(D:D,AGGREGATE(15,6,ROW(B$3:B$50)/(D$3:D$50<>""),ROWS(A$3:A3)-COUNTA(B$3:C$50))),"")))
This seems to work for now. Thank you!
I do agree that perhaps VBA would be a more elegant long-term solution...probably via a public function.
 
Upvote 0
Yes, more difficult characters were encountered, unfortunately. That column is a few thousand items long 😅

This seems to work for now. Thank you!
I do agree that perhaps VBA would be a more elegant long-term solution...probably via a public function.
You could try this user-defined function then.

VBA Code:
Function STACKCOLS(rng As Range) As Variant
  Dim Data As Variant, a As Variant
  Dim r As Long, c As Long, k As Long
  
  Data = rng.Value
  ReDim a(1 To Rows.Count)
  For c = 1 To UBound(Data, 2)
    For r = 1 To UBound(Data, 1)
      If Len(Data(r, c)) > 0 Then
        k = k + 1
        a(k) = Data(r, c)
      End If
    Next r
  Next c
  ReDim Preserve a(1 To k)
  STACKCOLS = Application.Transpose(a)
End Function

Demo here on a smaller data set.

MossyPants.xlsm
ABCD
1
2
3aadj
4bbek
5ccfl
6dgm
7ehn
8fi
9gj
10h
11i
12j
13j
14k
15l
16m
17n
18
Stack Columns (4)
Cell Formulas
RangeFormula
A3:A17A3=STACKCOLS(B3:D50)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top