Transposing inconsistent data?

D4V1D0

New Member
Joined
Feb 8, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi All,

First post and hoping it's not too much of a basic question to start my forum career as a drain on your collective knowledge....

I've been asked to look at improving a spreadsheet/process that involves taking rows of data and manipulating it into another format.

The cells are generally not in a consistent format, but I can work with the reporting system to rectify this over time and manually correct any errors until the source data is uniform.

In short, we're asked to take a cell and convert it in the following way:

Cell:

2x apple 4x pear 1x banana

Required Result:

apple
apple
pear
pear
pear
pear
banana

I've scratched my head and haven't managed to come up with a decent solution.

I did look at "Text to columns" using the "x" as a delimiter, then removing the "x" columns, which leaves me with this:

2​
apple
4​
pear
1​
banana

From here, I'm stuck as to how I can produce the desired result. Not sure if the above actually improves anything!

Any advice would be appreciated :)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi & welcome to MrExcel.
How about
Fluff.xlsm
AB
1
22x apple 4x pear 1x bananaapple
3apple
4pear
5pear
6pear
7pear
8banana
9
Data
Cell Formulas
RangeFormula
B2:B8B2=LET(a,TEXTSPLIT(A2,"x "," "),b,--INDEX(a,,1),TOCOL(IF(SEQUENCE(,MAX(b))<=b,INDEX(a,,2),1/0),2))
Dynamic array formulas.
 
Upvote 1
Hi & welcome to MrExcel.
How about
Fluff.xlsm
AB
1
22x apple 4x pear 1x bananaapple
3apple
4pear
5pear
6pear
7pear
8banana
9
Data
Cell Formulas
RangeFormula
B2:B8B2=LET(a,TEXTSPLIT(A2,"x "," "),b,--INDEX(a,,1),TOCOL(IF(SEQUENCE(,MAX(b))<=b,INDEX(a,,2),1/0),2))
Dynamic array formulas.
That is brilliant, thank you!

I'm just studying the formula to try and figure out how it works (these functions are new to me) and replicating it on my actual project. I've realised my source data will most likely be in this format:

"apple x 2 pear x 4 banana x 1"

I'm guessing this means I'll need to adjust the TEXTSPLIT part of the formula initially to recognise the fact that the x/fruit are now the other way around?

Apologies, I probably could have saved you some time by checking my facts the first time!
 
Upvote 0
Ok, how about
Excel Formula:
=LET(a,TEXTSPLIT(A2," x "," "),b,--INDEX(a,,2),TOCOL(IF(SEQUENCE(,MAX(b))<=b,INDEX(a,,1),1/0),2))
 
Upvote 0
Solution
That's great, I think that's cracked it for the most part, really appreciate your help on this :)

I think until our course data is consistent, there will be some manual workarounds needed, but this is amazing!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,970
Members
449,095
Latest member
Mr Hughes

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