ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Concatenate columns, variable number of rows (https://www.excelbanter.com/excel-programming/410964-concatenate-columns-variable-number-rows.html)

Dawn[_4_]

Concatenate columns, variable number of rows
 
I have a report that returns multiple rows per ID number. The columns always
stay the same. The number of rows per ID number is variable. I would like
to group the info per ID number into one cell. If the number of rows was
constant I could concatenate easily. But each ID number could have one row
or a hundred rows, it is completely variable. Can VBA be used to
concatenate?

The way the report currently looks, it gives the ID number in the first row,
then each subsequent row has the ID number blank until there is a new ID
number to show. This report comes out of a database.

Sample data:

ID Country Number
1234-5678 US 123456
[blank] GB 789123
[blank] IT 456789
4567-8912 US 23456
8912-3456 EP 1234567
[blank] US 8912345
[blank] JP 456789
[blank] CN 123456789
2345-6789 [blank]

So in this example what I want to end up with is two columns, on row per ID
number:

ID Related Matters (one cell)
1234-5678 US 123456; GB 789123; IT 456789
4567-8912 US 23456
8912-3456 EP 1234567; US 8912345; JP 456789; CN 123456789
2345-6789 [blank]

Thanks in advance for any help/ideas anyone can give!

dan dungan

Concatenate columns, variable number of rows
 
Do you import the report to excel or did you create the report in
excel?

Dawn[_4_]

Concatenate columns, variable number of rows
 
The report is coming from a database, going into excel format. I'm saving
into .csv. If I save into .xls it creates it so the the ID number cell spans
the multiple rows, instead of returning blank rows, if that makes any
difference.

I didn't create the report, however, it's just one I use. I'm not sure I
can get it to alter in format at all. Perhaps could get it altered to fill
in the blank ID numbers, but I'm not sure (just guessing that's what you're
wondering about)

"dan dungan" wrote:

Do you import the report to excel or did you create the report in
excel?



All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com