A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Deleting duplicate records



 
 
Thread Tools Display Modes
  #1  
Old December 8th, 2003, 10:34 PM
danldata
external usenet poster
 
Posts: n/a
Default Deleting duplicate records

I am trying to use a macro from the MS Knowledge base and
it isn't working. the macro is supposed to delete
duplicate records from a list in excel. If anyone knows
how to make this work I'd appreciate it greatly. I'm not
trained on macros or VB and was hoping to plug and play
with minor tweaks to the ranges and sheet number.

Sub DelDups_OneList()
Dim iListCount As Integer
Dim iCtr As Integer

' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False

' Get count of records to search through.
iListCount = Sheets("Sheet3").Range("A1:A7322").Rows.Count
Sheets("Sheet3").Range("A1").Select
' Loop until end of records.
Do Until ActiveCell = ""
' Loop through records.
For iCtr = 1 To iListCount
' Don't compare against yourself.
' To specify a different column, change 1 to the
column number.
If ActiveCell.Row Sheets("Sheet3").Cells(iCtr,
1).Row Then
' Do comparison of next record.
If ActiveCell.Value = Sheets("Sheet3").Cells
(iCtr, 1).Value Then
' If match is true then delete row.
Sheets("Sheet3").Cells(iCtr, 1).Delete
xlShiftUp
' Increment counter to account for deleted
row.
iCtr = iCtr + 1
End If
End If
Next iCtr
' Go to next record.
ActiveCell.Offset(1, 0).Select
Loop
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub


  #2  
Old December 8th, 2003, 10:58 PM
Don Guillett
external usenet poster
 
Posts: n/a
Default Deleting duplicate records

Now is a good time to learn how to use google. Get Ron's addin and search
for duplicates.
http://www.rondebruin.nl/

You didn't say if the duplicate should check one column or many columns.

--
Don Guillett
SalesAid Software

"danldata" wrote in message
...
I am trying to use a macro from the MS Knowledge base and
it isn't working. the macro is supposed to delete
duplicate records from a list in excel. If anyone knows
how to make this work I'd appreciate it greatly. I'm not
trained on macros or VB and was hoping to plug and play
with minor tweaks to the ranges and sheet number.

Sub DelDups_OneList()
Dim iListCount As Integer
Dim iCtr As Integer

' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False

' Get count of records to search through.
iListCount = Sheets("Sheet3").Range("A1:A7322").Rows.Count
Sheets("Sheet3").Range("A1").Select
' Loop until end of records.
Do Until ActiveCell = ""
' Loop through records.
For iCtr = 1 To iListCount
' Don't compare against yourself.
' To specify a different column, change 1 to the
column number.
If ActiveCell.Row Sheets("Sheet3").Cells(iCtr,
1).Row Then
' Do comparison of next record.
If ActiveCell.Value = Sheets("Sheet3").Cells
(iCtr, 1).Value Then
' If match is true then delete row.
Sheets("Sheet3").Cells(iCtr, 1).Delete
xlShiftUp
' Increment counter to account for deleted
row.
iCtr = iCtr + 1
End If
End If
Next iCtr
' Go to next record.
ActiveCell.Offset(1, 0).Select
Loop
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub




  #3  
Old December 11th, 2003, 10:03 PM
dandata
external usenet poster
 
Posts: n/a
Default Deleting duplicate records

Initially I am checking on just one column. It would be
better to be able to check on two or even more.


-----Original Message-----
Now is a good time to learn how to use google. Get Ron's

addin and search
for duplicates.
http://www.rondebruin.nl/

You didn't say if the duplicate should check one column

or many columns.

--
Don Guillett
SalesAid Software

"danldata" wrote in

message
...
I am trying to use a macro from the MS Knowledge base

and
it isn't working. the macro is supposed to delete
duplicate records from a list in excel. If anyone knows
how to make this work I'd appreciate it greatly. I'm not
trained on macros or VB and was hoping to plug and play
with minor tweaks to the ranges and sheet number.

Sub DelDups_OneList()
Dim iListCount As Integer
Dim iCtr As Integer

' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False

' Get count of records to search through.
iListCount = Sheets("Sheet3").Range

("A1:A7322").Rows.Count
Sheets("Sheet3").Range("A1").Select
' Loop until end of records.
Do Until ActiveCell = ""
' Loop through records.
For iCtr = 1 To iListCount
' Don't compare against yourself.
' To specify a different column, change 1 to the
column number.
If ActiveCell.Row Sheets("Sheet3").Cells(iCtr,
1).Row Then
' Do comparison of next record.
If ActiveCell.Value = Sheets("Sheet3").Cells
(iCtr, 1).Value Then
' If match is true then delete row.
Sheets("Sheet3").Cells(iCtr, 1).Delete
xlShiftUp
' Increment counter to account for

deleted
row.
iCtr = iCtr + 1
End If
End If
Next iCtr
' Go to next record.
ActiveCell.Offset(1, 0).Select
Loop
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub




.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:57 PM.


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