From column to cell based on starting number?

MikeSK

New Member
Joined
Jan 8, 2020
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have one column with file names like this:

1000-x.jpg
1000-y.jpg
1000-z.jpg
2000-f.jpg
2000-g.jpg
3000-s.jpg
...

I would like to add text (the same one) in front of the text and transpose this column that way, so cells texts with the same starting number will be in one cell separated by comma like this:

mytext.1000-x.jpg, mytext.1000-y.jpg, mytext.1000-z.jpg
mytext.2000-f.jpg, mytext.2000-g.jpg
mytext.3000-s.jpg
...

What would be the best way to approach this?

Thank you for your time.

Mike
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
If you are looking for a formula approach, here is one way provided your version of Excel 365 has the FILTER & UNIQUE functions.

Formula in column C goes in cell C2 only and the other values will automatically 'spill' down to other cells
Formula in column D gets copied down as far as you might neeed.

MikeSK 2020-07-15 1.xlsm
ABCD
1
21000-x.jpg1000mytext.1000-x.jpg, mytext.1000-y.jpg, mytext.1000-z.jpg
31000-y.jpg2000mytext.2000-f.jpg, mytext.2000-g.jpg
41000-z.jpg3000mytext.3000-s.jpg
52000-f.jpg 
62000-g.jpg 
73000-s.jpg
8
Sheet1
Cell Formulas
RangeFormula
C2:C4C2=UNIQUE(LEFT(A$2:A$7,FIND("-",A2:A7)-1))
D2:D6D2=IF(C2="","","mytext."&TEXTJOIN(", mytext.",1,FILTER(A$2:A$7,LEFT(A$2:A$7,LEN(C2))=C2)))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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