If And Issues

dantheman9

Board Regular
Joined
Feb 5, 2011
Messages
175
Hi im trying to use the following code to work if if the a brower should be refreshed.
However I seem to be having some issues with my If And Statement to check on if the page is ready to be refreshed.
code im using is below (paused varable values in comments)

Code:
If oldhtml < cellhtml Then     ' oldhtml value =333 cellhtml value = 333
Currtime = Now() + TimeValue(st)   
End If        ' on this run loop is skiped which is ok

If TimeValue(oldtime) = TimeValue("00:00:00") Then     ' oldtime value is a date = 14/06/11 11:50:59
oldtime = Currtime
End If    ' on this run this is also skiped which is ok

[COLOR=red]If oldhtml <= cellhtml And Timerun > oldtime Then   ' issues here - oldhtml 333 cellhtml 333 timerun(date) 14/06/11 11:31:21 oldtime as above so it should run but just skips over??? 
[/COLOR]With Browser
     .refresh
     End With
     Currtime = Now() + TimeValue(st)   ' used to update time for next refresh point
    oldtime = Currtime
     End If
 Timerun = Now() + TimeValue("00:04:00")    ' used to run whole sub again
      Application.OnTime Timerun, "DetectNewFiles"

My If And statement seems not to be working, yet all the correct data is in place to run the IF? or have i missedf something?

thanks for any help on this
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
NOW() produces a date/time value :- days as an int (37654) time as a decimal of a day

So check the value of oldtime

also Try

If (oldhtml <= cellhtml) And (Timerun > oldtime) Then

just to clarify the true false statements to be evaluated
 
Upvote 0
Code:
If oldhtml < cellhtml Then     ' oldhtml value =333 cellhtml value = 333
Currtime = Now() + TimeValue(st)   
End If        ' on this run loop is skiped which is ok
 
If TimeValue(oldtime) = TimeValue("00:00:00") Then     ' oldtime value is a date = [COLOR=red][B]14/06/11 11:50:59[/B][/COLOR]
oldtime = Currtime
End If    ' on this run this is also skiped which is ok
 
[COLOR=black]If oldhtml <= cellhtml And [COLOR=blue][B]Timerun > oldtime[/B][/COLOR] Then   ' issues here - oldhtml 333 cellhtml 333 timerun(date) [COLOR=red][B]14/06/11 11:31:21[/B][/COLOR] oldtime as above so it should run but just skips over??? [/COLOR]
Am I being thick here... Timerun isn't greater than oldtime, is it? Timerun is 14/06/11 11:31:21 and oldtime is 14/06/11 11:50:59, so the test returns False and the following code doesn't get executed.

Do you want to run the code if EITHER oldhtml <= cellhtml OR Timerun > oldtime is True?
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

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