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:

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,561
Messages
5,512,073
Members
408,878
Latest member
stams

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top