I'm trying to compare two dates with the format DD/MM/YYYY HH:MM AM/PM, the idea is that if one date is greater than the other it puts in a field the word "Before" or "After" if it's lower.
I've tried doing this but failed miserably.
For col = 0 To objSheet.UsedRange.Rows.Count
objSheet.Range("A2").Formula = "=IF(Value < B&(col+2), Before,After)"
Next
Line objSheet.Range("A2").Formula = "=IF(Value < B&(col+2), Before,After)"
seems to not throw any error but all I get in my excel file is #NAME?
Value is a string that contains the value to which the other string is going to be compared to. Example
' Value = 5/4/2016 8:00:00 PM
' Value in B column: 5/5/2016 12:00:00 PM
then the if should output = BEFORE but if
'Value in B column: 5/5/2016 2:00:00 AM
then the output should be AFTER
I've seen some diff_date function but it doesn't seem to be integrated because it doesn't show up as an option.
It's there a way to achieve this? What am I doing wrong?
vlue
then you formula would be:"=IF(""" & Vlue & """ < B" & col + 2 & ", Before,After)"
– Scott Craner