Splitting a column of data into corresponding columns

SSCOB

New Member
Joined
Sep 12, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello
I have a column of data containing numbers separate by commas which I need to split out into corresponding columns, as per:


Codes​
1​
2​
3​
4​
5​
6​
7​
8​
9​
10​
11​
12​
13​
14​
15​
16​
17​
18​
19​
20​
1,5,12,16,20​
1​
5​
12​
16​
20​
1,5,12,16,20​
1​
1​
1​
1​
1​

So, for example, in Cell A2 I have the numbers 1, 5, 12,16, 20,
Cell B2 is labelled 1, Cell C2 is labelled 2, Cell D2 is labelled 3, and so on up to say 20.
I then need to be able to move the numbers in A2 into the corresponding cells, so A2 above would then be split so that the '1' appears as '1' in the column labelled 1. the number 5 appears as 5 under the column labelled 5, and so on. Any other cells would remain blank.
I would also like to be able to do similar, but instead of the A3 numbers transferring as that number, I just need a 1.
E.g. Cell A3 above would then show as a 1 in the column labelled 1, a 1 in the column labelled 5, a 1 in the column labelled 12, etc.

Thank you!!! :)
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
You could try this with a formula...
Book1.xlsx
ABCDEFGHIJKLMNOPQRSTU
1Codes1234567891011121314151617181920
21,5,12,16,2015121620
31,5,12,16,2011111
Sheet18
Cell Formulas
RangeFormula
B2:U2B2=IF(ISNUMBER(MATCH(B1:U1,VALUE(TEXTSPLIT(A2,",")),0)),B1:U1,"")
B3:U3B3=IF(ISNUMBER(MATCH(B1:U1,VALUE(TEXTSPLIT(A3,",")),0)),1,"")
Dynamic array formulas.

Hope that helps,

Doug
 
Upvote 0
Solution
Hi @SSCOB and welcome to MrExcel:
In cell B3:
Excel Formula:
=IFERROR(IF(MATCHX(B$2:U$2,TEXTSPLIT(A3&",",,",")+0,0),B$2:U$2),"")

In cell B4:
Excel Formula:
=FERROR(IF(MATCHX(B$2:U$2,TEXTSPLIT(A3&",",,",")+0,0),1),"")
 
Upvote 0
You could try this with a formula...
Book1.xlsx
ABCDEFGHIJKLMNOPQRSTU
1Codes1234567891011121314151617181920
21,5,12,16,2015121620
31,5,12,16,2011111
Sheet18
Cell Formulas
RangeFormula
B2:U2B2=IF(ISNUMBER(MATCH(B1:U1,VALUE(TEXTSPLIT(A2,",")),0)),B1:U1,"")
B3:U3B3=IF(ISNUMBER(MATCH(B1:U1,VALUE(TEXTSPLIT(A3,",")),0)),1,"")
Dynamic array formulas.

Hope that helps,

Doug
Perfect, thank you!! :)
 
Upvote 0

Forum statistics

Threads
1,215,108
Messages
6,123,128
Members
449,097
Latest member
mlckr

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