Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Delete Duplicate row and Copy to another sheet

Dear All:

I have following data, what I m trying to do, records where both HOC
and STS are same, irrespective of IDATE/SDATE/RL. it

should be deleted from sheet1 and be copied on sheet 2. Would it
possible in macro.


IDATE PNAME STS RL SDATE
13/08/2006 HOC AT Y 14/08/2006
13/08/2006 HOC AG Y 23/08/2006
13/08/2006 HOC AG H 24/08/2006
13/08/2006 HOC UP Y 27/08/2006
13/08/2006 HOC FILE H 30/08/2006
14/08/2006 IASS AT H 15/08/2006
14/08/2006 IASS AG H 19/08/2006
14/08/2006 IASS UP H 22/08/2006
14/08/2006 IASS WDT H 23/08/2006
14/08/2006 IASS FILE H 24/08/2006
14/08/2006 IASS FILE H 27/08/2006

After impelmention the data should be like this


IDATE PNAME STS RL SDATE
13/08/2006 HOC AT Y 14/08/2006
13/08/2006 HOC AG Y 23/08/2006
13/08/2006 HOC UP Y 27/08/2006
13/08/2006 HOC FILE H 30/08/2006
14/08/2006 IASS AT H 15/08/2006
14/08/2006 IASS AG H 19/08/2006
14/08/2006 IASS UP H 22/08/2006
14/08/2006 IASS WDT H 23/08/2006
14/08/2006 IASS FILE H 24/08/2006

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Delete Duplicate row and Copy to another sheet

Something like this
Sub CopyDups()
Dim lastrow as Long, rw as Long
rw = 2
with worksheets("Sheet1")
lastrow = .cells(rows.count,2).end(xlup).row
for i = lastrow to 2 step -1
if .cells(i,2) = .cells(i-1,2) and _
.cells(i,3) - .cells(i-1,3) then
.rows(i).copy Worksheets("Sheet2").Cells(rw,1)
.rows(i).Delete
rw = rw + 1
end if
Next
End With
End Sub

--
Regards,
Tom Ogilvy


"-jawad" wrote:

Dear All:

I have following data, what I m trying to do, records where both HOC
and STS are same, irrespective of IDATE/SDATE/RL. it

should be deleted from sheet1 and be copied on sheet 2. Would it
possible in macro.


IDATE PNAME STS RL SDATE
13/08/2006 HOC AT Y 14/08/2006
13/08/2006 HOC AG Y 23/08/2006
13/08/2006 HOC AG H 24/08/2006
13/08/2006 HOC UP Y 27/08/2006
13/08/2006 HOC FILE H 30/08/2006
14/08/2006 IASS AT H 15/08/2006
14/08/2006 IASS AG H 19/08/2006
14/08/2006 IASS UP H 22/08/2006
14/08/2006 IASS WDT H 23/08/2006
14/08/2006 IASS FILE H 24/08/2006
14/08/2006 IASS FILE H 27/08/2006

After impelmention the data should be like this


IDATE PNAME STS RL SDATE
13/08/2006 HOC AT Y 14/08/2006
13/08/2006 HOC AG Y 23/08/2006
13/08/2006 HOC UP Y 27/08/2006
13/08/2006 HOC FILE H 30/08/2006
14/08/2006 IASS AT H 15/08/2006
14/08/2006 IASS AG H 19/08/2006
14/08/2006 IASS UP H 22/08/2006
14/08/2006 IASS WDT H 23/08/2006
14/08/2006 IASS FILE H 24/08/2006


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
copy duplicate rows to new sheet in WB SITCFanTN Excel Programming 0 June 28th 06 07:53 PM
How do i delete duplicate rows in an Excel Spread Sheet sqirt Excel Worksheet Functions 1 February 8th 06 03:04 PM
DELETE DUPLICATE DATA IN A SHEET AUTOMATICALLY Sony Manoj Excel Discussion (Misc queries) 1 November 20th 05 08:39 AM
Macro to copy duplicate rows (not delete) [email protected] Excel Programming 1 April 19th 05 12:30 PM
Macro - to copy duplicate rows to another sheet [email protected] Excel Worksheet Functions 2 April 19th 05 01:53 AM


All times are GMT +1. The time now is 07:57 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"