Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default How to compare two sheet using vba and remove duplicate content?

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






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default How to compare two sheet using vba and remove duplicate content?

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).Pastspeci al 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







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default How to compare two sheet using vba and remove duplicate conten

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).Pastspeci al 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
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
Compare Two Simple Workbooks & Remove Duplicate Rows Dave Excel Discussion (Misc queries) 9 July 25th 07 02:36 PM
How do I remove or filter out duplicate records in a sheet? geo Excel Discussion (Misc queries) 4 February 15th 06 10:50 PM
Identifying duplicate content in column excelstart[_3_] Excel Programming 3 January 9th 06 10:22 PM
Cell content elimination; duplicate BudD Excel Worksheet Functions 1 April 1st 05 12:52 AM
Can excel remove the duplicate rows in a spread sheet? Robert Moritzky Excel Programming 2 October 3rd 04 12:02 AM


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