Combine rows in excel to one row

Started by David, February 13, 2019, 03:37:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

David

Ok, I got one pain in the butt excel file.
It has several rows (not columns) that need to be combined into one cell, which if it was only a few, it wouldn't be that bad using the ole:
=A1&" "&A2&" "&A3&" "&A4&" "&A5 (except in this case it would be like e2, e3, e4, e5 and then e10, e11, e12, e13)

but, this file has lots of rows, some are 4 rows in one group, some are 3 rows in another group, then 4 rows, then another 4, etc...
( like e2, e3, e4 & e5 combined and then e10, e11, e12 & e13 combined, then e18 & e19, then another group...)

lather rinse repeat.
and this is for a variable data merge.

any suggestions?
a script perhaps?
a bigger margarita maybe?

 :drunk3:
 :hangme:


TIA
Prepress guy - Retired - Working from home
Livin' la Vida Loca

Joe

Definitely a bigger margarita. It won't help but you won't care anymore.

Sorry that is all I got.
Mac OS Sonoma 14.2.1 (c) | (retired)

The seven ages of man: spills, drills, thrills, bills, ills, pills and wills.

David

all I need is another reason to drink!

thanks Joe!
Prepress guy - Retired - Working from home
Livin' la Vida Loca

scottrsimons

Something like this, I would say the Excel out as a CSV, and then open it is BBEdit and do a GREP search based on a pattern like if there is a blank row in between the rows you need to combine:

Find (this would be for four rows only):
^(.*)&/r^(.*)&/r^(.*)&/r^(.*)&/r/r              /1         /2        /3        /4
^ = beginning of the line
(.*) = all characters, and the parens allows you to replace it as one pattern
& = end of the line
/r = hard return
/r/r = at the end and in between the rows you need to combine, hopefully there is a blank row

Replace:
/1 /2 /3 /4/r/1 = replace with pattern 1
/2 = replace with pattern 2
/3 = replace with pattern 3
/4 = replace with pattern 4
This will also put a space between the patterns and then a hard return at the end.
"Your superior intellect is no match for our puny weapons!" - Homer J. Simpson

pabney

If you have access to google sheets or Office Cloud, you can use the textjoin function.

https://support.google.com/docs/answer/7013992?hl=en

David

thanks for all the help!

I am attempting this and I'll let you know what works.

Cheers!
Prepress guy - Retired - Working from home
Livin' la Vida Loca

pspdfppdfxhd

I hope it is simpler, all that code is giving me a headache!

swampymarsh

Try:

Google Sheets > Add Ons > AbleBits: Merge Values

https://www.youtube.com/watch?v=VTZnCyfeE48