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


Hey everyone, I need to write a macro that checks if cell a2 is equal to
cell a3, and if so, deletes the entire row (the one that a2 is part
of).
I need this to run down about 1000 cells and continue to check and
delete, so i need it to be something like
if a2=a3 then 2:2 delete, if a3=a4, then 3:3 delete and so on, but is
there a way to automate this so you can assign the macro to a button,
and when you click it it goes through the list checking and deleting
rows?
Thanks guys


--
carlito_1985
------------------------------------------------------------------------
carlito_1985's Profile: http://www.excelforum.com/member.php...o&userid=21390
View this thread: http://www.excelforum.com/showthread...hreadid=399360

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Duplicate remover


Assuming your data is the range A1:A1000:

Sub DeleteRow

For i = 1000 to 1 Step-1
If Cells(i,"A")=Cells(i,"A").offset(-1,0) then
Cells(i,"A").EntireRow.Delete
End if
Next

End sub


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=399360

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Duplicate remover


If you are not sure of the number of rows in Column A, use:

Sub DeleteRow2()

numRows = Range("a65536").End(xlUp).row

For i = numRows to 1 Step-1
If Cells(i,"A")=Cells(i,"A").offset(-1,0) then
Cells(i,"A").EntireRow.Delete
End if
Next

End sub


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=399360

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
Does anyone know of any 'Smart' Duplicate Remover? msnyc07 Excel Discussion (Misc queries) 1 March 2nd 10 11:38 PM
Duplicate Remover CVandijk Excel Discussion (Misc queries) 1 November 25th 08 08:49 PM
Duplicate remover (no macro) RyanR8881 Excel Discussion (Misc queries) 1 October 7th 08 10:38 PM
unique item remover doc Excel Discussion (Misc queries) 1 November 13th 07 06:49 PM
Duplicate remover T-®ex[_28_] Excel Programming 0 August 26th 05 06:39 AM


All times are GMT +1. The time now is 07:30 PM.

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

About Us

"It's about Microsoft Excel"