Consolidating similar rows

kc.crow

Board Regular
Joined
Jul 7, 2005
Messages
75
Hello

I've searched quite a few places and I'm sure that I'm not using the correct keywords because this shouldn't be difficult.

I have data that has the same "keys" (ID, Name, Title) but will have other columns that may or may not have a value. Below is an example of what I mean.

ID| Name| Title| Field1| Field2| Field3
01| Joey| CEO| Value1
01| Joey| CEO| _______ Value2
01| Joey| CEO| _____________ Value3


What I'd like to be able to do is consolidate those three rows into 1 row:

ID| Name| Title| Field1| Field2| Field3
01| Joey| CEO| Value1| Value2| Value3


Access does this easily via a query but I haven't found something similar in Excel via its own functionality. Is there such an animal? If not, some helpful code would be great.

Thanks in advance!
Ron
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

jc.021286

Well-known Member
Joined
Apr 12, 2010
Messages
725
Hey there,

Indirectly you could quickly toss it into a pivot table with the 3 value fields as column vectors.

then simply copy paste special values to quickly get it to sum/identify everything in your desired format.

jc
 

kc.crow

Board Regular
Joined
Jul 7, 2005
Messages
75
Thanks for the reply. This for something that will be automated for all of the rows that are generated. I'm not sure that the Pivot Table would be the best solution for this sort of thing. I will keep that in mind, however.


Thanks,
Ron
 

jc.021286

Well-known Member
Joined
Apr 12, 2010
Messages
725
your other option imo would be to do a quick setup with the sumproduct formula.
Data A:E
Create your table G:K
01 Joey
02 Silvester
03 Greg

and in your value 1 through 3 you would have
Field1=sumproduct(--($A:$A=$G1),--($B:$B=$H1),C:C)
Field2=sumproduct(--($A:$A=$G1),--($B:$B=$H1),D:D)
Field3=sumproduct(--($A:$A=$G1),--($B:$B=$H1),E:E)
--note(set first one up and drag formula over, the $ signs will ensure it works)
this would do what you want and would automatically update when new values are populated.

Your ID and names will need to be consistent and you ought to be good,
--note(you may be able to drop the name sections (--($B:$B=$H1)) if your ID field is unique.

Regards,
jc
 

kc.crow

Board Regular
Joined
Jul 7, 2005
Messages
75

ADVERTISEMENT

Thanks again, jc. The formula is returning 0 rather than "A" for the first person and Field1. I think it's because SUMPRODUCT is doing math where I really want to find the "non-blank" or "max" value for the matching index. Does that make sense?
 

kc.crow

Board Regular
Joined
Jul 7, 2005
Messages
75

ADVERTISEMENT

You are using numeric values so it works great for that. Try using text values. Then you will get 0's because the formula is doing math. I need to pull the text value.

Thanks again!
 

jc.021286

Well-known Member
Joined
Apr 12, 2010
Messages
725
Ah okay,

that changes things :biggrin:, you are correct that the sumproduct cannot be used on text values and neither could the pivot table for that matter.

Indexing would be best then
<a href=http://www.filedump.net/dumped/test21280432114.zip>http://www.filedump.net/dumped/test21280432114.zip</a>

the other option is if your data always moves in threes. The offset function would be my next resort
doing something such as
=offset(D$2,3*row($A1)-1,0)

that will index by moving in groupings of 3.

if neither of those work for you, I'm officially out of ideas for ya besides resorting to VBA, lol.

jc
 

kc.crow

Board Regular
Joined
Jul 7, 2005
Messages
75
This makes sense. Unfortunately, the number of rows is not uniform so I'll test this out on larger volumes of data for performance purposes.

Thanks for all your great help!

Ron
 

Watch MrExcel Video

Forum statistics

Threads
1,133,278
Messages
5,657,816
Members
418,414
Latest member
ECMdusty

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
Top