Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I compare two sheets and output a report?

Scenario:
Sheet 1 has 500 entries with the columns Last Name, First Name, Email Address
Sheet 2 has 3000 entries with the columns Buddy Name, Last Name, First Name,
IM Platform

Problem:
I need to compare Sheet 1 against Sheet 2 for matches between the First and
Last name. Where it finds a match I need to correlate the Buddy Name with
that person in some fashion (i.e. say on Sheet 3 output Rob Smith,
, hotdog23, MSN)

Any help would be greatly appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default How do I compare two sheets and output a report?

Somethign like this should work (or get you very close):
Sub Match()

r1 = Worksheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
r2 = Worksheets("sheet2").Cells(Rows.Count, "A").End(xlUp).Row

Set r3 = Worksheets("sheet1")
Worksheets("sheet2").Range("B2").Select
For a = 2 To r2
For i = 2 To r1
If Cells(a, "A") = r3.Cells(i, "A") Then
temp = r3.Cells(i, "B")
te = te & "," & temp
Else
End If
Next i
Cells(a, "B") = te
te = ""
Next a
End Sub


Sub Match2()
Dim myCon As String
Dim myCell As Range
Dim cell As Range
For Each cell In Sheet2.Range("C2:C10")

myCon = ""
For Each myCell In Sheet1.Range("B2:B15")

If cell.Value < "" Then

If cell = myCell Then
If myCon = "" Then

myCon = myCell.Offset(0, 1) & ", " & myCell.Offset(0, -1)
Else
myCon = myCon & ", " & myCell.Offset(0, 3)

End If
End If
End If
Next myCell
cell.Offset(0, 3) = myCon
Next cell

End Sub

Backup your data before running this macro!! This macro, or any macro out
there, could product unintended consequences; hate to see you lose valuable
data...

HTH,
Ryan--
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Paresh" wrote:

Scenario:
Sheet 1 has 500 entries with the columns Last Name, First Name, Email Address
Sheet 2 has 3000 entries with the columns Buddy Name, Last Name, First Name,
IM Platform

Problem:
I need to compare Sheet 1 against Sheet 2 for matches between the First and
Last name. Where it finds a match I need to correlate the Buddy Name with
that person in some fashion (i.e. say on Sheet 3 output Rob Smith,
, hotdog23, MSN)

Any help would be greatly appreciated

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I compare two sheets and output a report?

Hi Ryan,

Thank you very much for your response. A couple of questions:

1. How/Where do I paste your code in Excel? How do I execute it?
2. The 4th line you have Set r3 = Worksheets("sheet1"). Does this variable
refer to the output? If so should it be "sheet3"?

"ryguy7272" wrote:

Somethign like this should work (or get you very close):
Sub Match()

r1 = Worksheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
r2 = Worksheets("sheet2").Cells(Rows.Count, "A").End(xlUp).Row

Set r3 = Worksheets("sheet1")
Worksheets("sheet2").Range("B2").Select
For a = 2 To r2
For i = 2 To r1
If Cells(a, "A") = r3.Cells(i, "A") Then
temp = r3.Cells(i, "B")
te = te & "," & temp
Else
End If
Next i
Cells(a, "B") = te
te = ""
Next a
End Sub


Sub Match2()
Dim myCon As String
Dim myCell As Range
Dim cell As Range
For Each cell In Sheet2.Range("C2:C10")

myCon = ""
For Each myCell In Sheet1.Range("B2:B15")

If cell.Value < "" Then

If cell = myCell Then
If myCon = "" Then

myCon = myCell.Offset(0, 1) & ", " & myCell.Offset(0, -1)
Else
myCon = myCon & ", " & myCell.Offset(0, 3)

End If
End If
End If
Next myCell
cell.Offset(0, 3) = myCon
Next cell

End Sub

Backup your data before running this macro!! This macro, or any macro out
there, could product unintended consequences; hate to see you lose valuable
data...

HTH,
Ryan--
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Paresh" wrote:

Scenario:
Sheet 1 has 500 entries with the columns Last Name, First Name, Email Address
Sheet 2 has 3000 entries with the columns Buddy Name, Last Name, First Name,
IM Platform

Problem:
I need to compare Sheet 1 against Sheet 2 for matches between the First and
Last name. Where it finds a match I need to correlate the Buddy Name with
that person in some fashion (i.e. say on Sheet 3 output Rob Smith,
, hotdog23, MSN)

Any help would be greatly appreciated

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
Please help with report output! 49niner Excel Worksheet Functions 2 March 13th 08 08:41 PM
how to compare two columns and get a output from it [email protected] Excel Worksheet Functions 3 July 5th 06 08:19 AM
Compare data with in a couple of sheets then output to a blank sheet Sabo, Eric Excel Programming 0 February 22nd 06 03:00 PM
report output format Tim3057[_3_] Excel Programming 1 January 16th 06 03:00 PM
Need help with report output....macro??? shane476 Excel Programming 1 July 29th 04 10:17 PM


All times are GMT +1. The time now is 11:34 AM.

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"