Link Multiple Fields

BradleyS

Active Member
Joined
Oct 28, 2006
Messages
351
Office Version
  1. 2010
Platform
  1. Windows
I can't figure out a resolve to my issue.

I have 2 tabs of list data

Tab 1 includes the following:


Tab 2 includes the following:


What I would like to do is match the User ID and only display lines from both tab if the eventdates match as well.

This can be presented on a seperate sheet or highlight each line of data that matches User_ID and Eventdate.

I'm trying to find out what type of Category was entered when these reviews were recorded.
The only common fields are the User_ID and Eventdate.

Is this possible?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
As an example:
If there is no match, nothing is shown.
If it finds a match, (even a single one) it displays the data from the other table.
 
Upvote 0
This should do what you want:

<code>
Sub findmatches()
Dim userid As Double
Dim eventdate As Double
Dim match As Boolean
Dim numberofmatches As Double

Sheets("sheet1").Cells.Interior.ColorIndex = 0
Sheets("sheet2").Cells.Interior.ColorIndex = 0
Sheets("sheet1").Range("d:f").ClearContents
Sheets("sheet1").Range("d1").Value = "USERID"
Sheets("sheet1").Range("e1").Value = "DATE"
Sheets("sheet1").Range("d1").Value = "USERID"
match = False
numberofmatches = 0


For Each cell In Sheets("sheet1").Range("a2", Sheets("sheet1").Range("a64000").End(xlUp))
userid = cell.Value
eventdate = cell.Offset(0, 1).Value
For Each cell2 In Sheets("sheet2").Range("a2", Sheets("sheet2").Range("a64000").End(xlUp))
If cell2.Value = userid And cell2.Offset(0, 1).Value = eventdate Then
cell2.EntireRow.Interior.ColorIndex = 6
cell.Offset(0, 3).Value = cell2.Value
cell.Offset(0, 4).Value = cell2.Offset(0, 1).Value
cell.Offset(0, 5).Value = cell2.Offset(0, 2).Value
match = True
numberofmatches = numberofmatches + 1
Else
End If
Next
If match = True Then
cell.EntireRow.Interior.ColorIndex = 6
Else
End If
match = False

Next
If numberofmatches = 0 Then Sheets("sheet1").Range("d1:f1").ClearContents
MsgBox numberofmatches, vbOKOnly, "Number of Matches Found"
End Sub

<code>
 
Upvote 0

Forum statistics

Threads
1,225,072
Messages
6,182,696
Members
453,132
Latest member
nsnodgrass73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top