Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Rows - only deletes content Phil Excel Discussion (Misc queries) 2 March 12th 10 04:43 PM
Filling only cells for rows with content Colin Hayes Excel Worksheet Functions 1 April 28th 07 02:46 PM
Highting rows based on content of cells Sarah Excel Worksheet Functions 1 January 24th 07 09:44 PM
deleting content in cells Vin Excel Programming 0 February 25th 04 09:31 AM
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content rmaloy Excel Programming 5 February 9th 04 01:59 AM


All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"