Recent

Author Topic: Combine rows in excel to one row  (Read 391 times)

0 Members and 1 Guest are viewing this topic.

Offline david

  • WTF?
  • Global Moderator
  • Supreme Ninja
  • *****
  • Posts: 15084
  • Gender: Male
  • arrrrrrrggg....
Combine rows in excel to one row
« on: February 13, 2019, 04:37:03 PM »
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 - doin' jobs one at a time

Offline Joe

  • Master of Nothing
  • Administrator
  • Ninja Warlord
  • *****
  • Posts: 36704
  • Gender: Male
    • B4Print.com
Re: Combine rows in excel to one row
« Reply #1 on: February 13, 2019, 05:01:32 PM »
Definitely a bigger margarita. It won't help but you won't care anymore.

Sorry that is all I got.
Mac OS 10.14.6 Mojave | Prinergy 8.2 | Adobe Creative Cloud 2019 | Two Luscher XPose 160 CTP units

Prepress: One who does precision guess work based on unreliable data provided by those of questionable knowledge.

Offline david

  • WTF?
  • Global Moderator
  • Supreme Ninja
  • *****
  • Posts: 15084
  • Gender: Male
  • arrrrrrrggg....
Re: Combine rows in excel to one row
« Reply #2 on: February 13, 2019, 05:17:10 PM »
all I need is another reason to drink!

thanks Joe!
Prepress guy - doin' jobs one at a time

Offline scottrsimons

  • Prepress/IT/Automation
  • Sr. Member
  • ****
  • Posts: 284
  • Gender: Male
Re: Combine rows in excel to one row
« Reply #3 on: February 14, 2019, 08:16:15 AM »
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):
Code: [Select]
^(.*)&/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:
Code: [Select]
/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.
Mac • Prinergy 8 • Preps 8 • RBA • Fusion Pro

"Your superior intellect is no match for our puny weapons!" - Homer J. Simpson

"Those who make you mad, control you."

Offline pabney

  • Jr. Member
  • **
  • Posts: 61
Re: Combine rows in excel to one row
« Reply #4 on: February 14, 2019, 11:09:42 AM »
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

Offline david

  • WTF?
  • Global Moderator
  • Supreme Ninja
  • *****
  • Posts: 15084
  • Gender: Male
  • arrrrrrrggg....
Re: Combine rows in excel to one row
« Reply #5 on: February 14, 2019, 05:08:05 PM »
thanks for all the help!

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

Cheers!
Prepress guy - doin' jobs one at a time

Offline pspdfppdfxhd

  • Ninja Member
  • *
  • Posts: 2554
  • Gender: Male
Re: Combine rows in excel to one row
« Reply #6 on: February 15, 2019, 09:02:20 AM »
I hope it is simpler, all that code is giving me a headache!

Offline swampymarsh

  • Full Member
  • ***
  • Posts: 155
Re: Combine rows in excel to one row
« Reply #7 on: February 15, 2019, 09:21:01 AM »
Try:

Google Sheets > Add Ons > AbleBits: Merge Values

Code: [Select]
https://www.youtube.com/watch?v=VTZnCyfeE48