PC Review


Reply
Thread Tools Rate Thread

How to compare two sheet using vba and remove duplicate content?

 
 
geniusideas
Guest
Posts: n/a
 
      26th Aug 2009
Hi, need urgent help
I have 2 sheets need to compare and delete duplicate content using VBA
For Example :
Before
Sheet1
A B C
222 Diode D506
333 Capasitor C123 - duplicate row
132 Transistor T525
555 Coil CL121 - duplicate row

Sheet2
333 Capasitor C123 - duplicate row
555 Coil CL121 - duplicate row
555 Coil CL121 - duplicate row x 2
444 Diode D444
444 Transistor T444

After
Sheet1
222 Diode D506
132 Transistor T525

Sheet2
444 Diode D444
444 Transistor T444
555 Coil CL121

Meaning I have to remove duplicate row inbetween sheet1 and sheet2
base on one to one.
Pls help to give me VBA code on how to do.
Thanks






 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      26th Aug 2009
its easy if you haev everything in one sheet

'select table to copy
sheet2.Range("A1").CurrentRegion.Copy
'now paste it below existing data
Sheet1.Range("A1").End(xldown).Offset(1).Pastspecial xlall
application.cutcopymode = false
'sort the new table off column A
range("A1").Sort Range("A1")
' remove duplicates
for rw = range("A1").end(xldown).row to 2 step -1
if cells(rw,1) = cells(rw-1,1) then
rows(rw).delete
end if
next



"geniusideas" wrote:

> Hi, need urgent help
> I have 2 sheets need to compare and delete duplicate content using VBA
> For Example :
> Before
> Sheet1
> A B C
> 222 Diode D506
> 333 Capasitor C123 - duplicate row
> 132 Transistor T525
> 555 Coil CL121 - duplicate row
>
> Sheet2
> 333 Capasitor C123 - duplicate row
> 555 Coil CL121 - duplicate row
> 555 Coil CL121 - duplicate row x 2
> 444 Diode D444
> 444 Transistor T444
>
> After
> Sheet1
> 222 Diode D506
> 132 Transistor T525
>
> Sheet2
> 444 Diode D444
> 444 Transistor T444
> 555 Coil CL121
>
> Meaning I have to remove duplicate row inbetween sheet1 and sheet2
> base on one to one.
> Pls help to give me VBA code on how to do.
> Thanks
>
>
>
>
>
>
>

 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      26th Aug 2009
check for typos!

i had 'Pastspecial' and it should be Pastespecial

use Edit/Compile before runnign code.
sorry, I'm in a hurry


"Patrick Molloy" wrote:

> its easy if you haev everything in one sheet
>
> 'select table to copy
> sheet2.Range("A1").CurrentRegion.Copy
> 'now paste it below existing data
> Sheet1.Range("A1").End(xldown).Offset(1).Pastspecial xlall
> application.cutcopymode = false
> 'sort the new table off column A
> range("A1").Sort Range("A1")
> ' remove duplicates
> for rw = range("A1").end(xldown).row to 2 step -1
> if cells(rw,1) = cells(rw-1,1) then
> rows(rw).delete
> end if
> next
>
>
>
> "geniusideas" wrote:
>
> > Hi, need urgent help
> > I have 2 sheets need to compare and delete duplicate content using VBA
> > For Example :
> > Before
> > Sheet1
> > A B C
> > 222 Diode D506
> > 333 Capasitor C123 - duplicate row
> > 132 Transistor T525
> > 555 Coil CL121 - duplicate row
> >
> > Sheet2
> > 333 Capasitor C123 - duplicate row
> > 555 Coil CL121 - duplicate row
> > 555 Coil CL121 - duplicate row x 2
> > 444 Diode D444
> > 444 Transistor T444
> >
> > After
> > Sheet1
> > 222 Diode D506
> > 132 Transistor T525
> >
> > Sheet2
> > 444 Diode D444
> > 444 Transistor T444
> > 555 Coil CL121
> >
> > Meaning I have to remove duplicate row inbetween sheet1 and sheet2
> > base on one to one.
> > Pls help to give me VBA code on how to do.
> > Thanks
> >
> >
> >
> >
> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare sheet utility that can compare formula too Adam2046 Microsoft Excel Discussion 3 27th Apr 2010 09:26 AM
Duplicate sheet, autonumber sheet, record data on another sheet des-sa Microsoft Excel Worksheet Functions 0 8th May 2008 06:56 PM
Compare Two Simple Workbooks & Remove Duplicate Rows =?Utf-8?B?RGF2ZQ==?= Microsoft Excel Misc 9 25th Jul 2007 02:36 PM
How do I remove or filter out duplicate records in a sheet? =?Utf-8?B?Z2Vv?= Microsoft Excel Misc 4 15th Feb 2006 10:50 PM
Can excel remove the duplicate rows in a spread sheet? =?Utf-8?B?Um9iZXJ0IE1vcml0emt5?= Microsoft Excel Programming 2 3rd Oct 2004 12:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:42 PM.