View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default matching two columns in two separate sheets against one another...

Try the macro below. Change the Const statements as necessary. You didn't
give enough details to write specific code for your application.


Sub GetTerminations()
Const SumSheet = "summary"
Const BilingualSheet = "bilingual employees"
Const TermSheet = "termination"
Const TermLastName = "A"
Const TermFirstName = "B"
Const BiLastName = "A"
Const BiFirstName = "B"
Const SumLastName = "A"
Const SumFirstName = "B"

SumRowCount = 1
TermRowCount = 1

With Sheets(TermSheet)
Do While .Range(TermLastName & TermRowCount) < ""
LastName = .Range(TermLastName & TermRowCount)
FirstName = .Range(TermFirstName & TermRowCount)
With Sheets(BilingualSheet)
BiRowCount = 1
Do While .Range(BiLastName & BiRowCount) < ""
If (.Range(BiLastName & BiRowCount) = LastName) And _
(.Range(BiFirstName & BiRowCount) = FirstName) Then

With Sheets(SumSheet)
.Range(SumFirstName & SumRowCount) = FirstName
.Range(SumLastName & SumRowCount) = LastName
SumRowCount = SumRowCount + 1
End With
Exit Do
End If
BiRowCount = BiRowCount + 1
Loop
End With
TermRowCount = TermRowCount + 1
Loop
End With

End Sub

"jcontrer" wrote:

What i have:
I have three different spreadsheets; one with all of the bilingual employees
of a company and their qualifications, another is a list of all the
terminations for that company, which i get monthly but i have a backlog
because no one has done it in the past three years (which is a substantial
number) and the last is a spreadsheet which is now blank but with the same
format as the first spreadsheet mentioned.

What i want to do with what i have:
I want to use the second sheet mentioned earlier as the search criteria (i
want to search by first and last name) and i want to search for names in the
rows of the bilingual sheet that match the first and last name of someone in
the terminations sheet and then have the row in sheet 1 marked (maybe
highlighted) so i can cut the name out of the bilingual sheet (or it can be
cut out of the first sheet sheet and pasted to the third sheet automatically,
which would be easier). and put it in the third sheet which will serve as a
storage sheet for terminated employees so that if we get sued i'd still have
that persons qualifications information to cover me.


--
thanks in advance