Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find, Match, Copy from onesheet to other

Hi all
Look at my codes below.It does matches two columns in old and new
worksheet and copies it into other sheet.
All together there are 3 worksheets.
I want now two worksheets.
Worksheet(Old) and worksheet(new).
In both sheets it matches two columns A and B. After matching it it
copies it to the 3rd sheet named Oldmatch.
Now I want that when the Column A and B of old matches with A and B of
new. Then it should select the
entire row data from old starting from ColC and copy it to worksheet
named New in the corresponding match AB
in Col C of New worksheet.




With Worksheets("New")
Set rngNewA = .Range(.Cells(2, "A"), _
..Cells(Rows.Count, "A").End(xlUp))
End With
With Worksheets("Old")
Set rngOldA = .Range(.Cells(2, "A"), _
..Cells(Rows.Count, "A").End(xlUp))
End With
rowMatchAB = 1
rowMatchAonly = 1
rowNoMatch = 1
shMatchAB = "Oldmatch"
shMatchAonly = "Oldonematch"
shnoMatch = "Oldnomatch"

For Each celold In rngOldA
MatchResults = "NoMatch"
For Each celNew In rngNewA
If celold.Value = celNew.Value Then
' At least A range matches
If celold(1, 2).Value = celNew(1, 2).Value Then
'A and H range matches
MatchResults = "AB"

Else
'Only A range matches
If MatchResults < "AB" Then
MatchResults = "A"

End If
End If
End If
'No match yet, keep looking
Next celNew
If MatchResults = "AB" Then
'Matches A And B
celold.EntireRow.Copy Destination:= _
Worksheets(shMatchAB).Cells(rowMatchAB, "A")
rowMatchAB = rowMatchAB + 1
ElseIf MatchResults = "A" Then
' Only A matches
celold.EntireRow.Copy Destination:= _
Worksheets(shMatchAonly).Cells(rowMatchAonly, "A")
rowMatchAonly = rowMatchAonly + 1
ElseIf MatchResults = "NoMatch" Then
'No match
celold.EntireRow.Copy Destination:= _
Worksheets(shnoMatch).Cells(rowNoMatch, "A")


End If
Next celold




Any help would be appreciated .

Thanx in advance.
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
Urgent:Find match between two worksheets and copy to another sheet guru Excel Worksheet Functions 1 September 21st 09 07:41 PM
Find match between cells and copy data Kcope8302 Excel Worksheet Functions 7 September 18th 09 11:55 PM
find closest match and copy to sheet1 saman110 via OfficeKB.com Excel Discussion (Misc queries) 5 October 29th 07 06:09 PM
Find closest match and copy saman110 via OfficeKB.com Excel Discussion (Misc queries) 3 August 31st 07 06:30 AM
Urgent help(Find, match and copy) Lolly[_2_] Excel Programming 0 August 25th 04 02:05 PM


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