Find and dates data across sheets

Computerised10

New Member
Joined
Oct 2, 2014
Messages
20
Hi all,

i have a workbook which consists of 2 sheets. in each sheet i have a unique ID and the date next to it such as

sheet 1

98531
11/10/2014
86521b
8/8/2014
66363d
1/1/2014

<tbody>
</tbody>

sheet 2
86521b
10/8/2014
9853115/10/2014
66363d
6/1/2014

<tbody>
</tbody>

what i need to do is first find the data from sheet 2 which matches sheet 1. then minus sheet two date from sheet 1 to give me the amount of days difference.

any help will be much appreciated
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
You really do need to give more precise details of what is wrong when posting.

The only one I can see that looks wrong is Sheet1-Sheet2. Try the code below and if it still gives incorrect answers give some detail of what is coming up wrong and I will look at it later in the day.

Rich (BB code):
Sub xxx2()
    Dim c As Range, y As Long, x As Long

    With Sheets("Sheet1")

        For Each c In .Range("A1:A" & .Range("A" & Rows.Count).End(xlUp).Row)
            y = Sheets("Sheet2").Columns("A:A").Find(What:=c.Value, After:=Sheets("Sheet2").Cells(1, 1), LookIn:=xlFormulas, _
                                                     LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Offset(, 1)

            c.Offset(, 2) = CLng(c.Offset(, 1)) - CLng(y)

            y = Sheets("Sheet3").Columns("A:A").Find(What:=c.Value, After:=Sheets("Sheet3").Cells(1, 1), LookIn:=xlFormulas, _
                                                     LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Offset(, 1)

            x = Sheets("Sheet2").Columns("A:A").Find(What:=c.Value, After:=Sheets("Sheet2").Cells(1, 1), LookIn:=xlFormulas, _
                                                     LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Offset(, 1)
            c.Offset(, 3) = CLng(x) - CLng(y)

            y = Sheets("Sheet4").Columns("A:A").Find(What:=c.Value, After:=Sheets("Sheet4").Cells(1, 1), LookIn:=xlFormulas, _
                                                     LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Offset(, 1)

            x = Sheets("Sheet3").Columns("A:A").Find(What:=c.Value, After:=Sheets("Sheet3").Cells(1, 1), LookIn:=xlFormulas, _
                                                     LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Offset(, 1)
            c.Offset(, 4) = CLng(x) - CLng(y)

        Next

    End With

End Sub
 
Upvote 0
That done the Trick!

one last question, it wont run if one of the fields in column A or B are empty on all four sheets. as this is progressively filled in these fields are filled in at later dates. so i need it to run even if one field is empty.

you have been more than helpful and i am humbled by your efforts
 
Upvote 0

Forum statistics

Threads
1,215,305
Messages
6,124,153
Members
449,146
Latest member
el_gazar

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