Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Deleteing Duplicate Rows???

Hi Experts

I have a excel sheet of over 5000 rows of data (I get a
differnt one every week). Is their a way to delete a
duplicate, triplicate etc (it could have unlimited number
of same data) based on Value in Column A. i.e Value in
Column A are determining factor in deciding which row
should be considered duplicate.
I would ike to achieve this totaly through VBA in Excel
2002. I would appricate in your help if its possible.

Thanks a lot
James
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Deleteing Duplicate Rows???

Hi
see: http://www.cpearson.com/excel/deleti...eDuplicateRows

--
Regards
Frank Kabel
Frankfurt, Germany


James wrote:
Hi Experts

I have a excel sheet of over 5000 rows of data (I get a
differnt one every week). Is their a way to delete a
duplicate, triplicate etc (it could have unlimited number
of same data) based on Value in Column A. i.e Value in
Column A are determining factor in deciding which row
should be considered duplicate.
I would ike to achieve this totaly through VBA in Excel
2002. I would appricate in your help if its possible.

Thanks a lot
James

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Deleteing Duplicate Rows???

James,

Here is a very quick way of doing it

Sub filterData()
Dim cRows As Long
Dim rng As Range
Dim testFormula As String

Application.ScreenUpdating = False

Columns("G:G").Insert
Rows(1).Insert
Cells(1, "G").Value = "Temp"

With ActiveSheet
cRows = .Cells(.Rows.Count, "F").End(xlUp).Row
testFormula = "=IF(COUNTIF(F$2:F2,F2)1,""Y"" ,"""")"
'create a test formula
.Cells(2, "G").Formula = testFormula
'copy the formula down all rows
.Cells(2, "G").AutoFill Destination:=.Range(.Cells(2, "G"), _
.Cells(cRows, "G"))
Set rng = .Range("G:G")
rng.AutoFilter Field:=1, Criteria1:="Y"

End With

rng.SpecialCells(xlCellTypeVisible).EntireRow.Dele te

Columns("G:G").Delete

Application.ScreenUpdating = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"James" wrote in message
...
Hi Experts

I have a excel sheet of over 5000 rows of data (I get a
differnt one every week). Is their a way to delete a
duplicate, triplicate etc (it could have unlimited number
of same data) based on Value in Column A. i.e Value in
Column A are determining factor in deciding which row
should be considered duplicate.
I would ike to achieve this totaly through VBA in Excel
2002. I would appricate in your help if its possible.

Thanks a lot
James



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleteing Duplicate Rows???

Hi guys,

is there a way of deleting rows, on the basis that a cell in th
particular rows, contains a word like "closed" or "suspended"

e.g rows c4 to c450 contains a, b, c, d, e and i want to delete all th
rows containing "a" in that particular column using macros.

can you please help me out??

Thanks Cathal

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Deleteing Duplicate Rows???

Hi
try the following macro
Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
with Cells(RowNdx, "C")
if .value = "a" then
Rows(RowNdx).Delete
End If
end with
Next RowNdx
Application.ScreenUpdating = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


Hi guys,

is there a way of deleting rows, on the basis that a cell in the
particular rows, contains a word like "closed" or "suspended"

e.g rows c4 to c450 contains a, b, c, d, e and i want to delete all
the rows containing "a" in that particular column using macros.

can you please help me out??

Thanks Cathal.


---
Message posted from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleteing Duplicate Rows???

Sub Tester1()
Dim rng as Range, rng1 as Range
Set rng = Range(Range("C4"),Cells(rows.count,3).End(xlup))
rng.Replace What:="a", Replacement:="=Na()", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False
On Error Resume Next
set rng1 = rng.SpecialCells(xlCellTypeFormulas, xlErrors)
On Error goto 0
If not rng1 is nothing then
rng1.EntireRow.Delete
End if
End Sub

--
Regards,
Tom Ogilvy

"CPower " wrote in message
...
Hi guys,

is there a way of deleting rows, on the basis that a cell in the
particular rows, contains a word like "closed" or "suspended"

e.g rows c4 to c450 contains a, b, c, d, e and i want to delete all the
rows containing "a" in that particular column using macros.

can you please help me out??

Thanks Cathal.


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Deleteing Duplicate Rows???

Sub filterData()
Dim cRows As Long
Dim rng As Range
Dim testFormula As String

Application.ScreenUpdating = False

Columns("G:G").Insert
Rows(1).Insert
Cells(1, "G").Value = "Temp"

With ActiveSheet
cRows = .Cells(.Rows.Count, "F").End(xlUp).Row
testFormula = "=IF(F2=""a"",""Y"" ,"""")"
'create a test formula
.Cells(2, "G").Formula = testFormula
'copy the formula down all rows
.Cells(2, "G").AutoFill Destination:=.Range(.Cells(2, "G"), _
.Cells(cRows, "G"))
Set rng = .Range("G:G")
rng.AutoFilter Field:=1, Criteria1:="Y"

End With

rng.SpecialCells(xlCellTypeVisible).EntireRow.Dele te

Columns("G:G").Delete

Application.ScreenUpdating = True

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CPower " wrote in message
...
Hi guys,

is there a way of deleting rows, on the basis that a cell in the
particular rows, contains a word like "closed" or "suspended"

e.g rows c4 to c450 contains a, b, c, d, e and i want to delete all the
rows containing "a" in that particular column using macros.

can you please help me out??

Thanks Cathal.


---
Message posted from http://www.ExcelForum.com/



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleteing Duplicate Rows???

Thanks a million for the help guys, this has worked for me

--
Message posted from http://www.ExcelForum.com

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleteing Duplicate Rows???

I am now gettting an error when i put in multiple if statements, coul
someone please let me know where i am going wrong??
i don't want the code to be dependent on the word in inverted comms.

here is where i am getting the error messgae.....

Dim RowNdx As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
With Cells(RowNdx, "F")
If .Value = "Prioritization" Then
Rows(RowNdx).Delete
End If
If .Value = "Dev Analysis" Then ........on this line here???
Rows(RowNdx).Delete
End If
If .Value = "Suspend" Then
Rows(RowNdx).Delete
End If
If .Value = "Escalated" Then
Rows(RowNdx).Delete
End If

Thanks,
Catha

--
Message posted from http://www.ExcelForum.com

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Deleteing Duplicate Rows???

Cathal,

Because you delete a row, the With statement has no object. Try this version

Dim RowNdx As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
With Cells(RowNdx, "F")
If .Value = "Prioritization" Then
Rows(RowNdx).Delete
ElseIf .Value = "Dev Analysis" Then
Rows(RowNdx).Delete
ElseIf .Value = "Suspend" Then
Rows(RowNdx).Delete
ElseIf .Value = "Escalated" Then
Rows(RowNdx).Delete
End If
End With
Next RowNdx

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CPower " wrote in message
...
I am now gettting an error when i put in multiple if statements, could
someone please let me know where i am going wrong??
i don't want the code to be dependent on the word in inverted comms.

here is where i am getting the error messgae.....

Dim RowNdx As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
With Cells(RowNdx, "F")
If .Value = "Prioritization" Then
Rows(RowNdx).Delete
End If
If .Value = "Dev Analysis" Then ........on this line here???
Rows(RowNdx).Delete
End If
If .Value = "Suspend" Then
Rows(RowNdx).Delete
End If
If .Value = "Escalated" Then
Rows(RowNdx).Delete
End If

Thanks,
Cathal


---
Message posted from http://www.ExcelForum.com/





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleteing Duplicate Rows???

Cheers bob, perfect,

Thanks,
Cathal

--
Message posted from http://www.ExcelForum.com

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleteing Duplicate Rows???

Is there any chance you get me some code to delete a row on the basi
that a cell in one of its columns contains text. My reason for this i
that, the row is relavant if the problem report column is empty, wher
as if it has some text in it like CYUFR1234 it must be deleted from th
spreadsheet.

Thanks again,
Cathal

--
Message posted from http://www.ExcelForum.com

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Deleteing Duplicate Rows???

Dim RowNdx As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx,"F").Value < "" Then
Cells(RowNdx,"F").Entirerow.Delete
End If
Next RowNdx


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CPower " wrote in message
...
Is there any chance you get me some code to delete a row on the basis
that a cell in one of its columns contains text. My reason for this is
that, the row is relavant if the problem report column is empty, where
as if it has some text in it like CYUFR1234 it must be deleted from the
spreadsheet.

Thanks again,
Cathal.


---
Message posted from http://www.ExcelForum.com/



  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleteing Duplicate Rows???

Thanks bob

--
Message posted from http://www.ExcelForum.com

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
Deleteing empty rows Ken G. Excel Discussion (Misc queries) 3 June 28th 05 01:18 AM
Deleteing some Rows Deepwater Excel Discussion (Misc queries) 1 April 1st 05 06:23 PM
Deleteing Rows Amber[_2_] Excel Programming 3 February 4th 04 06:34 PM
Deleteing Blank Rows Tim Otero Excel Programming 0 August 12th 03 05:23 PM
Deleteing Blank Rows Tom Ogilvy Excel Programming 0 August 12th 03 04:29 PM


All times are GMT +1. The time now is 10:21 PM.

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"