Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting Rows where some Cells have same Content
Hello
I am after a Macro that will delete rows where information is the same in defined columns.... I have data that is similar to the following, but extends across several comumns, but I only want to conern the macro with the first 3 colums for instance: Name Book Language James Flowers French James Flowers French James Flowers German Name Book Language James Flowers French James Flowers German I want it to leave me with, can anyone help with a VB Macro? thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting Rows where some Cells have same Content
Sub DeleteDups()
Dim i As Long i = 2 Do While Not IsEmpty(Cells(i, 1)) If Cells(i, 1) = Cells(i - 1, 1) And _ Cells(i, 2) = Cells(i - 1, 2) And _ Cells(i, 3) = Cells(i - 1, 3) Then Cells(i, 1).EntireRow.Delete Else i = i + 1 End If Loop End Sub -- Regards, Tom Ogilvy "JamesT" wrote in message ... Hello I am after a Macro that will delete rows where information is the same in defined columns.... I have data that is similar to the following, but extends across several comumns, but I only want to conern the macro with the first 3 colums for instance: Name Book Language James Flowers French James Flowers French James Flowers German Name Book Language James Flowers French James Flowers German I want it to leave me with, can anyone help with a VB Macro? thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting Rows where some Cells have same Content
It stops when it finds a blank cell. If you really have a header row and
your data starts in row 3, then here is the adjustment: Sub DeleteDups() Dim i As Long i = 4 Do While Not IsEmpty(Cells(i, 1)) If Cells(i, 1) = Cells(i - 1, 1) And _ Cells(i, 2) = Cells(i - 1, 2) And _ Cells(i, 3) = Cells(i - 1, 3) Then Cells(i, 1).EntireRow.Delete Else i = i + 1 End If Loop End Sub -- Regards, Tom Ogilvy "JamesT" wrote in message ... Thanks Tom I tried to run the Script on the following very simplified sheet where I am conerned with Title/Platform and Prog as my sear criteria... Where Title and Platform and Program are the same I want the duplicates deleted irrespective of Pack and Doc. The Script did not work on this and I do not know how to alter it - Any suggestions? title platform prog pack doc a ps2 e e e a ps2 f f f a ps2 f g g a ps2 g I l b ps2 e t t b xbox e g g c ps2 e hg hg c pccd e gf gf "Tom Ogilvy" wrote: Sub DeleteDups() Dim i As Long i = 2 Do While Not IsEmpty(Cells(i, 1)) If Cells(i, 1) = Cells(i - 1, 1) And _ Cells(i, 2) = Cells(i - 1, 2) And _ Cells(i, 3) = Cells(i - 1, 3) Then Cells(i, 1).EntireRow.Delete Else i = i + 1 End If Loop End Sub -- Regards, Tom Ogilvy "JamesT" wrote in message ... Hello I am after a Macro that will delete rows where information is the same in defined columns.... I have data that is similar to the following, but extends across several comumns, but I only want to conern the macro with the first 3 colums for instance: Name Book Language James Flowers French James Flowers French James Flowers German Name Book Language James Flowers French James Flowers German I want it to leave me with, can anyone help with a VB Macro? thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting Rows - only deletes content | Excel Discussion (Misc queries) | |||
Filling only cells for rows with content | Excel Worksheet Functions | |||
Highting rows based on content of cells | Excel Worksheet Functions | |||
deleting content in cells | Excel Programming | |||
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content | Excel Programming |