TimeDiff Type Mismatch

csand

New Member
Joined
Jul 21, 2009
Messages
9
Code:
If ((DateDiff((Cells(nRow, 7).Value), Date, "d") > 1) & ((DateDiff(Date, (Cells(nRow, 8).Value), "d")) > 1)) Then
            Sheets("Sheet").Cells(nRow, 33) = "Active"
End If

When my macro runs through the above code, I get a type mismatch error. All of the cells are formatted at Date only.

Any ideas?

Thank you.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
If you want to check for a date use IsDate.

Also make sure you are referring to the correct worksheet when you use Cells(nRow, 7).Value etc

Without a worksheet reference then that's going to refer to what VBA considers as the active sheet.

Another thing to check for is errors, if these 'dates' are the results of formulas that could be possible.:)
 
Upvote 0
Code:
Sheets("CopyPaste").Select
If ((DateDiff("d", (Cells(nRow, 7).Value), Date) > 1) [COLOR=red][B]&[/B][/COLOR] ((DateDiff("d", Date,(Cells(nRow, 8).Value))) > 1)) Then
            Sheets("Sheet").Cells(nRow, 33) = "Active"
End If

I change the code and still have the same error.

I think you have an "&" where there should be a "+"
 
Upvote 0
Also... just noted your operator is wrong in the formula..

Should be one of the following<>= AND OR not & this is a concatenator operand
 
Upvote 0
Actually I think the & might want to be an And.

That is if you are trying some sort of logical operation.:)
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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