Merging two (or more) columns together to skip blanks

MurdochQuill

Board Regular
Joined
Nov 21, 2020
Messages
84
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I'm using the below formula to merge columns together, but I'm wondering how I can skip blanks on the input data. The formula I'm using assumes that the ranges are static, however I am also looking to make it a dynamic formula which can handle blank cells, in which case it should skip & then add the next column instead.
Current:
Book1
BCDEF
1List 1List 2Output
2JamieJohnJamie
3JacobJulieJacob
4JesusJesus
5JaneJane
6JamesJames
7John
8Julie
Sheet1
Cell Formulas
RangeFormula
F2F2=IFERROR(INDEX($B$2:$B$6, ROWS(C1:$C$1)), IFERROR(INDEX($D$2:$D$3, ROWS(C1:$C$1)-ROWS($B$2:$B$6)), ""))
F3:F8F3=IFERROR(INDEX($B$2:$B$6, ROWS(C$1:$C2)), IFERROR(INDEX($D$2:$D$3, ROWS(C$1:$C2)-ROWS($B$2:$B$6)), ""))


However I'm hoping to achieve this:
Book1
BCDEF
1List 1List 2Output
2JamieJohnJamie
3JacobJulieJacob
4James
5Jesus
6Jeff
7Julius
8JamesJohn
9JesusJulie
10Jeff
11 
12Julius 
Sheet1
Cell Formulas
RangeFormula
F2F2=IFERROR(INDEX($B$2:$B$8, ROWS(C1:$C$1)), IFERROR(INDEX($D$2:$D$3, ROWS(C1:$C$1)-ROWS($B$2:$B$8)), ""))
F3,F11:F12F3=IFERROR(INDEX($B$2:$B$8, ROWS(C$1:$C2)), IFERROR(INDEX($D$2:$D$3, ROWS(C$1:$C2)-ROWS($B$2:$B$8)), ""))


Any help would be great.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Roughly how many cells will be involved?
 
Upvote 0
Ok, how about
+Fluff 1.xlsm
ABCDEFG
1
2WaverleyTest ValleyStockton-on-TeesWaverley
3LambethHackneyHounslowLambeth
4BathEast HertfordshireHorshamBath
5ExeterStaffordNewhamExeter
6LutonNorth TynesideNorth East LincolnshireLuton
7Waltham ForestNottinghamWindsor and MaidenheadWaltham Forest
8Brighton and HoveSwindonLeicesterBrighton and Hove
9WakefieldSheffieldWakefield
10Three RiversElmbridgeThree Rivers
11BlabyHaringey
12Leeds
13Test Valley
14Hackney
15East Hertfordshire
16Stafford
17HaringeyNorth Tyneside
18LeedsNottingham
19Swindon
20Stockton-on-Tees
21Hounslow
22Horsham
23Newham
24North East Lincolnshire
25Windsor and Maidenhead
26Leicester
27Sheffield
28Elmbridge
29Blaby
30
Main
Cell Formulas
RangeFormula
G2:G29G2=LET(Rngs,(A2:A20,C2:C20,E2:E20),Rws,ROWS(INDEX(Rngs,,,1)),Seq,SEQUENCE(AREAS(Rngs)*Rws,,0),Ary,INDEX(Rngs,MOD(Seq,Rws)+1,1,INT(Seq/Rws)+1),FILTER(Ary,Ary<>""))
Dynamic array formulas.


All the ranges must be the same size.
 
Upvote 0
Solution
Ok, how about
+Fluff 1.xlsm
ABCDEFG
1
2WaverleyTest ValleyStockton-on-TeesWaverley
3LambethHackneyHounslowLambeth
4BathEast HertfordshireHorshamBath
5ExeterStaffordNewhamExeter
6LutonNorth TynesideNorth East LincolnshireLuton
7Waltham ForestNottinghamWindsor and MaidenheadWaltham Forest
8Brighton and HoveSwindonLeicesterBrighton and Hove
9WakefieldSheffieldWakefield
10Three RiversElmbridgeThree Rivers
11BlabyHaringey
12Leeds
13Test Valley
14Hackney
15East Hertfordshire
16Stafford
17HaringeyNorth Tyneside
18LeedsNottingham
19Swindon
20Stockton-on-Tees
21Hounslow
22Horsham
23Newham
24North East Lincolnshire
25Windsor and Maidenhead
26Leicester
27Sheffield
28Elmbridge
29Blaby
30
Main
Cell Formulas
RangeFormula
G2:G29G2=LET(Rngs,(A2:A20,C2:C20,E2:E20),Rws,ROWS(INDEX(Rngs,,,1)),Seq,SEQUENCE(AREAS(Rngs)*Rws,,0),Ary,INDEX(Rngs,MOD(Seq,Rws)+1,1,INT(Seq/Rws)+1),FILTER(Ary,Ary<>""))
Dynamic array formulas.


All the ranges must be the same size.
I'm continually amazed by your Excel skills. Nice solution, very neat.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,830
Members
449,096
Latest member
Erald

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