Need Helping hand here….my code seems weird :) Thanks for help:

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi,
Happy Friday:biggrin:

I think i need some help here. I have this code which I dont know how to make it work.Hilighted region is where i'm getting error..

Please modify whi
Code:
Sub DT_try()
 d1 = Range("A" & Rows.Count).End(xlUp).Value
 d2 = Date & " " & Time
 'd3 = d2-d1
 'if d3 < "1:00:00" Then
 Range("B5").Value = d1
 Range("B6").Value = d2
[COLOR=yellowgreen] If d2 - d1 < "1:00:00" Then[/COLOR]
 MsgBox "<"
 Else
 MsgBox ">"
 End If
End Sub
 
Maybe ...
Code:
Sub DT_try()
    d1 = Range("A" & Rows.Count).End(xlUp).Value
    d2 = Now
    Range("B5").Value = d1
    Range("B6").Value = d2
    
    If d2 - d1 < #1:00:00 AM# Then
        MsgBox "<"
    Else
        MsgBox ">"
    End If
End Sub
 
Upvote 0
Works perfect. Okay I want to call macro1 if d2-d1 > 9 will this work if Am is there in the format?
Thanks again
What I mean is can it be in format "37:30:55" or 24 hrs...in case it does not work..
Code:
Sub DT_try7()
    d1 = Range("A" & Rows.Count).End(xlUp).Value
    d2 = Now
    Range("B5").Value = d1
    Range("B6").Value = d2
 
    If d2 - d1 > #9:00:00 AM# Then
        MsgBox "> gtr"
        call macro1
 
    Else
        MsgBox "< less"
    End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,840
Messages
6,193,279
Members
453,788
Latest member
drcharle

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