Parsing a list of numbers

stefanaalten

Board Regular
Joined
Feb 1, 2011
Messages
68
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm struggling to come up with a way of producing the output I'm after. My data is as shown below:

IDListItem 1Item 2Item 3
A1,2
TRUE​
TRUE​
FALSE​
B
2​
FALSE​
TRUE​
FALSE​
C
FALSE​
FALSE​
FALSE​
D1,2,3
TRUE​
TRUE​
TRUE​

For each entry in my list (column A, ID's A-D) I have a list of numbers (column B). I would like to populate the columns Item 1, etc. with true/false values based on whether the item occurs in the list. It should be simple parsing function shouldn't it, but I'm not really sure how to go about it - can anyone please help? My actual list has 50 items, i.e. columns for Item 1 - Item 50. The lists (in column B) will not consist of more than 5 items, and I can ensure they are in ascending numeric order if that helps the formula.
I'd be really grateful for a bit of help! At the moment I'm populating the values in the Item columns manually, which is error-prone!
Kind regards,
Stefan
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Thanks for that. I need to modify the formula slightly to work with my real data, but struggling with that ?.
Firstly, there will be 50 "item" columns. Secondly, the headings will actually be "Pad 1 Score", "Pad 2 Piccolo", "Pad 3 Flute 1", "Pad 4 Flute 2", ... "Pad 37 Baritone/Euphonium", ... "Pad 50 Various Others", so how should I modify the formula to allow for that? As it stands the formula works with up to 9 columns and does not permit the suffix text.
Sorry to be such a numpty. I've tried to work it out for myself.
 
Upvote 0
First, if you can change "TRUE" for like "YES", and "FALSE" for like "NO", it will save you a lot of headache, because the words TRUE and FALSE in excel are not very well handled by it, so avoid those.

So, let's say you change that. Now you can add two rows in your header, before your data.
Row one, is just to number each PAD(1 , 2, 3, 4 and so on)
Row two, you put the description just as "Score", "Piccolo", "Flute", "Flute" and so on, just like you mentioned.
Row three, you concatenate the information with a simple formula, then copy this formula to the other columns.

=CONCATENATE("Pad ";C1;" ";C2)

(just as shown in the image below).

Now for the columns B, that will put everything together, the formula is:

=CONCATENATE(
IF(C4="YES";$C$1&",";"");
IF(D4="YES";$D$1&",";"");
IF(E4="YES";$E$1&",";"");
IF(F4="YES";$F$1&",";"");
IF(G4="YES";$G$1&",";"");
IF(H4="YES";$H$1&",";"");
IF(I4="YES";$I$1&",";""))

Put this formula in cell B4

As you can see, is not beautiful, but it works, and to add new columns, just one of the rows in the formula above, and change the columns letter.

I hope you get it :).
 

Attachments

  • parsing list of numbers.png
    parsing list of numbers.png
    175.9 KB · Views: 4
Upvote 0
Thanks gtwo but that's not what I'm trying to accomplish. I'm trying to do the reverse: using the lists in column B I want to populate the columns C, D, E with true/false (or yes/no - it doesn't really matter) based on whether the corresponding number appears in the list.
In the meantime, I have found an article, How to split text string in Excel by comma, space, character or mask, that provides some help but it doesn't address my specific scenario as I will only have values in a few of the columns (the article gives help on how to split a string where all columns have a value).
 
Upvote 0
something like this?

Book1
ABCDE
1Pad 1 ScorePad 2 PiccoloPad 3 Flute 1Pad 3 Flute 2
2
3Pad 1 Score, Pad 2 Piccolo, Pad 3 Flute 1,TrueTrueTrueFalse
4Pad 3 Flute 1,FalseFalseTrueFalse
5Pad 2 Piccolo, Pad 3 Flute 1,FalseTrueTrueFalse
Sheet4
Cell Formulas
RangeFormula
B3:E5B3=IFERROR(IF(FIND(B$1,$A3),TRUE),FALSE)
 
Upvote 0
As long as your table wont change format and your items will run in numerical order from 1 to x left to right then you can cheat a little with:
=NOT(ISERROR(SEARCH(COLUMN(A1),$B9)))

Drop this into column 3 (where item 1 should be)

This works as column(a1) returns 1 and when you drag the formula right it'll return column b (2) column c (3) etc, unlike above and all the other formulas, it doesn't attempt to grab the number from the header and instead relies on where the column is in the worksheet. Iserror just returns true or false depending on whether the number can be found in the list and NOT reverses a True to False (as if the search function returns an error then iserror will be true and you want it false)

Cheers,

Tom
 
Upvote 0
Tom, I like your solution but it doesn't seem to work correctly - e.g. if I enter "10" in column B, then it results in TRUE for Item 10 but also for Item 1, and ditto if I enter "12" in column B then I get TRUE for Item 12 but also for Item 1 and Item 2 - ???
 
Upvote 0
Hi, here is another option along similar lines of post#8

Cell Formulas
RangeFormula
C2:L7C2=ISNUMBER(FIND(","&COLUMNS($C2:C2)&",",","&$B2&","))
 
Upvote 0

Forum statistics

Threads
1,215,701
Messages
6,126,308
Members
449,308
Latest member
VerifiedBleachersAttendee

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