View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ty Ty is offline
external usenet poster
 
Posts: 72
Default Matching Rows 2nd try

On Aug 13, 5:11*pm, "Don Guillett" wrote:
* * * If desired, send your file to my address below along with this msg and
a clear explanation of what you want and before/after examples.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Ty" wrote in message

...



This is part of the long thread with the subject Vlookup & Copy. *I
finally have an idea on what is needed to solve this problem after
stepping through the code.


1. *I need this section to output the results on another
Sheet=Sheet3.
2. *ID & Employee should be swapped. *Each Employee has a number of
ID's.
3. *Is it possible to do another match for the Col C:sheet1 to the
results/output of Col A? *If there is a match copy all of that ROW
from Col C:Col O on the same row as that matching Employee.
4. *Is it possible to do #3 the same time as the Matching is being
done to Sheet2?


Sub MatchingRows()
* '
* ' NOTE: The macro assumes there is a header in the both worksheets
* ' * * * The macro starts at row 2 and sort data automatically
* '
* ScreenUpdating = False


* 'get first empty row of sheet1
* With Sheets("Sheet1")
* * *LastRow = .Range("A" & Rows.Count).End(xlUp).Row
* * *NewRow = LastRow + 1
* End With


* 'find matching rows in sheet 2
* With Sheets("Sheet2")
* * *RowCount = 2
* * *Do While .Range("A" & RowCount) < ""
* * * * ID = Trim(.Range("A" & RowCount))
* * * * Employee = Trim(.Range("B" & RowCount))
* * * * 'compare - look for ID in Sheet 1
* * * * With Sheets("Sheet1")
* * * * * *Set c = .Columns("A").Find(what:=ID, _
* * * * * * * LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
* * * * * *If Not c Is Nothing Then
* * * * * * * 'add to end of sheet 1
* * * * * * * .Range("A" & NewRow) = ID
* * * * * * * .Range("B" & NewRow) = Employee
* * * * * * * NewRow = NewRow + 1
* * * * * *End If
* * * * End With


* * * * RowCount = RowCount + 1
* * *Loop
* End With


Thanks for your help...- Hide quoted text -


- Show quoted text -


Thanks for your response. I will send over examples and pictures.