View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
[email protected] mojocojo2000@gmail.com is offline
external usenet poster
 
Posts: 6
Default Combine data in rows based on two citeria

On Jun 19, 1:03 pm, Dave Peterson wrote:
It looks like you're keeping the first row that has the information on it.

How about this?

With your data in A2:C7 (headers in row 1)
I added a formula in D2: =a2&"..."&b2
and dragged down.

Then I selected the range (A1:D7 for me) and sorted by:
Column D in ascending order
column C in descending order
(with headers checked)

Then I added another formula in E2: =CountIf(D$2:D2,D2)
and dragged down
This ended up with 1's in the first entry for that company/city combination.

I filtered to show the values greater than 1 and deleted those visible rows.

Then I deleted my helper columns (D:E).





" wrote:

On Jun 19, 9:21 am, "
wrote:
I've have not yet come across a very good solution to this. Any help
would be very much appreciated.


I need a macro that is able to iterate through the rows of my data and
then for each row it iterates through takes two pieces of data from
columns of that row (eg: Company and City). It then finds other rows
containing the same data for both Company and City and combines the
data of these rows into only one row.


Here's a representation of my problem:


Befo
After:


Company: City: Address: -------
Company: City: Address:
Company1 City1 444 Broadway
Company1 City1 444 Broadway
Company2 City2
Company2 City2 333 Milburry
Company2 City2 333 Milburry
Company3 City3 111 West
Company1 City1
Company1 City4 666 East
Company3 City3 111 West
Company1 City4 666 East


Thanks in advance to anyone that helps.


Here's a better representation (it got messed up the first time I
typed it):


Company: City: Address:
Company1 City1 444 Broadway
Company2 City2
Company2 City2 333 Milburry
Company1 City1
Company3 City3 111 West
Company1 City4 666 East


After:


Company: City: Address:
Company1 City1 444 Broadway
Company2 City2 333 Milburry
Company3 City3 111 West
Company1 City4 666 East


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thank you very much. This is just what I needed.