Excel and Macros

March 23, 2010 at 15:04:49
Specs: XP
Hi this forum has been such an help for me in the last while and i need to call on it again.

Basically I have to sheets of data i need someway of comparing the rows in sheet 1 with the rows in sheet 2.

I then need to be able to then copy any non duplicates into sheet 3.

Any help is greatly appreciated

See More: Excel and Macros

Report •

March 23, 2010 at 15:50:33

Are you comparing row 1 on sheet 1 with row 1 on sheet 2, etc.
or is it
row 1 on sheet 1 with any or all rows on sheet 2, i.e, does a row on sheet 1 match any row on sheet 2

In either case is the match based on a single field (column) or does there need to be a match between more than one column or all columns.
Which columns must match (please give column letters)

When rows are copied to sheet 3 do they just go into the next empty row or do they go into the same row as the source (sheet 1 row) or the match (sheet 2 row).


Report •

March 23, 2010 at 16:10:30
Thank you for your speedy reply :)

At the minute they will be no resemblance in rows between the sheets so data in row 1 sheet 1 maybe duplicated in row 50 sheet 2.

I dont mind how it gets inserted into the 3rd sheet cause i can organise the data after that.

I hope this best answers your questions

Report •

March 23, 2010 at 16:18:04
Think i have it solved with this code here

Sub DoCompare()
Dim cel As Range, tgt As Range
With Sheets("Sheet2")
For Each cel In Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
If Sheets("Sheet1").Columns(1).Find(cel) Is Nothing Then
Set tgt = Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Offset(1)
If tgt.Row < 11 Then Set tgt = Sheets("Sheet3").Cells(11, 1)
cel.Resize(, 4).Copy tgt
End If
End With
End Sub

Thankyou though and reference has to go to this post here http://www.vbaexpress.com/forum/sho... as this is not my code


Report •

Related Solutions

Ask Question