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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Possibly try something like the code below (assumes that your id's are in column A and dates are in column B on both sheets)

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

    With Sheets("Sheet2")

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

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

        Next
    End With

End Sub
 
Upvote 0
"An error" doesn't mean anything to me. What does the error actually state exactly.
 
Upvote 0
hey

i thought if i had the basic formula i would be able to apply it to sheet3 and sheet4, but i cant :(.

so what i need done is the same thing but to sheet3 and sheet2 but output data to column d as sheet 1 outputs to column c. i hope that makes sense.

a
b
c
d
8554c
11/10/14
7
data from sheet3 here
8666d
12/6/14
6
data from sheet3 here

<tbody>
</tbody>

<tbody>
</tbody>
 
Last edited:
Upvote 0
OK, lets try and get this clear.
Are you subtracting column B Sheet3 from column B Sheet2? and you are putting the output to what sheet in column D?

Basically fill in the question marks below.

subtracting Sheet? column? from Sheet? column?, output to Sheet? column?
 
Upvote 0
ok its a sequence.

first i subtract columnB Sheet 2 from columnB Sheet 1 out put to columnC sheet 1
second i subtract ColumnB sheet 3 from columnb sheet 2 out put to columnD sheet 1
third i subtract columnB Sheet 4 from CoumnB sheet3 out put to columnE sheet 1
 
Upvote 0
Untested...

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(y) - CLng(c.Offset(, 1))

            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
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,552
Messages
6,120,172
Members
448,948
Latest member
spamiki

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