ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Deleting rows with same address (https://www.excelbanter.com/excel-discussion-misc-queries/207928-deleting-rows-same-address.html)

Noel

Deleting rows with same address
 
I have a spreadsheet with 6 columns; 1-name (last name, first name),
2-address1, 3-address2 4-city, 5-state and 6-zip code. The spreadsheet shows
members of my organization. I am trying to stop sending two mailings to the
same address to save postage.

I need help in creating a formula or a macro to:

1. Sort by zip code, state, city, address1 and address2
2. Check to see if address is the same as one above.
3. If so, check to see if last name is the same as one above
4. If 3 & 4 are yes, take the first name of the second row and add it to
the first name of the first row, insert an ampersand (&) [e.g. Jane & Joe Doe)
5. Delete the second row

Any and all help will be appreciated!
--
NOEL@HOME

Don Guillett

Deleting rows with same address
 

Fairly simple. Easier if you just send your wb to my address below instead
of me re-creating it.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"noel" wrote in message
...
I have a spreadsheet with 6 columns; 1-name (last name, first name),
2-address1, 3-address2 4-city, 5-state and 6-zip code. The spreadsheet
shows
members of my organization. I am trying to stop sending two mailings to
the
same address to save postage.

I need help in creating a formula or a macro to:

1. Sort by zip code, state, city, address1 and address2
2. Check to see if address is the same as one above.
3. If so, check to see if last name is the same as one above
4. If 3 & 4 are yes, take the first name of the second row and add it to
the first name of the first row, insert an ampersand (&) [e.g. Jane & Joe
Doe)
5. Delete the second row

Any and all help will be appreciated!
--
NOEL@HOME



Don Guillett

Deleting rows with same address
 
Sent this

Sub combinenames()
mc = 2 'col B

lr = Cells(Rows.Count, mc).End(xlUp).Row
For i = lr To 2 Step -1

If Cells(i - 1, mc) = Cells(i, mc) Then
p1 = InStr(Cells(i - 1, mc - 1), ",") - 1

If Left(Cells(i - 1, mc - 1), p1) = Left(Cells(i, mc - 1), p1) Then
Cells(i - 1, mc - 1).Value = Cells(i - 1, mc - 1) _
& " &" & Right(Cells(i, mc - 1), Len(Cells(i, mc - 1)) - p1 - 1)
Rows(i).Delete
End If

End If
Next i
Columns(1).Columns.AutoFit

'sort
Range("A1:G" & lr).Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...

Fairly simple. Easier if you just send your wb to my address below instead
of me re-creating it.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"noel" wrote in message
...
I have a spreadsheet with 6 columns; 1-name (last name, first name),
2-address1, 3-address2 4-city, 5-state and 6-zip code. The spreadsheet
shows
members of my organization. I am trying to stop sending two mailings to
the
same address to save postage.

I need help in creating a formula or a macro to:

1. Sort by zip code, state, city, address1 and address2
2. Check to see if address is the same as one above.
3. If so, check to see if last name is the same as one above
4. If 3 & 4 are yes, take the first name of the second row and add it to
the first name of the first row, insert an ampersand (&) [e.g. Jane & Joe
Doe)
5. Delete the second row

Any and all help will be appreciated!
--
NOEL@HOME





All times are GMT +1. The time now is 06:59 AM.

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