View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.misc
Lost in Alabama
 
Posts: n/a
Default How do I remove Duplicate rows?

Terry,

Thank you so much for sharing this information.

Lost

"Terry Pfeifer" wrote:



"Ken Hudson" wrote:

Here is a macro solution, assuming that row 1 has headers.
Right click on any worksheet (tab) at the bottom of your workbook.
Select View Code.
Go to InsertModule and copy and paste the code from below into the module.
Close the visual basic editor.
Back at your workbook go to ToolsMacroMacros... and run the macro.
Be sure to save a copy of your workbook beforehand.

---------------------------------------------------

Sub DeleteDupes()
Dim Iloop As Integer
Dim Numrows As Integer

'Turn off warnings, etc.
Application.ScreenUpdating = False
Application.DisplayAlerts = False

Numrows = Range("A65536").End(xlUp).Row
Range("A1:B" & Numrows).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, _
Key2:=Range("B1"), Order2:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
For Iloop = Numrows To 2 Step -1
If Cells(Iloop, "A") + Cells(Iloop, "B") = Cells(Iloop - 1, "A") + _
Cells(Iloop - 1, "B") Then
Rows(Iloop).Delete
End If
Next Iloop

'Turn on warnings, etc.
Application.DisplayAlerts = True
Application.ScreenUpdating = True

--
Ken Hudson


"85225" wrote:

I have an excel spreadsheet that has 2 columns. Col A is customer# and Col B
is invoice #.
A customer# can have many invoice#s
A customer# can have many rows with the same inv#.
An invoice# can only be associated with 1 customer#

I need to create a spreadsheet that shows each customer with the associated
invoice#. Each customer#/invoice# should only show once.

for example:

cust# invoice#
1 100
1 100
1 101
2 200
3 300
3 300


The result would be:

cust# inv#
1 100
1 101
2 200
3 300

How do I get rid of the extra rows?