How to set time for processing the code?

E

Eric

Does anyone have any suggestions on how to set time for processing the code?
I would like to add a condition that allow process the code before 4 pm,
Does anyone have any suggestions on how to do it?
Thanks in advance for any suggestions
Eric

If FileDateTime(PathFileName) > Date + TimeSerial(8, 0, 0) Or Now <
TimeSerial(16, 0, 0) Then {It does not work!}
 
F

FSt1

hi
Sub sheetnamesonSheet()

Dim r As Range
Dim rd As Range
Dim WS As Worksheet
Set r = Range("A2") 'change if needed. used sheet1 for demo
For Each WS In Worksheets
Set rd = r.Offset(1, 0)
r.Value = WS.Name
Set r = rd
Next WS
End Sub

goes in a standard module.

regards
FSt1
 
E

Eric

If FileDateTime(PathFileName) > Date + TimeSerial(8, 0, 0) Then {It is
working!}

I would like to add another condition that allow process the code before 4
pm, which I tried and show below, but it does not work.

If FileDateTime(PathFileName) > Date + TimeSerial(8, 0, 0) Or Now <
TimeSerial(16, 0, 0) Then {It does not work!}

Do you have any suggestions?
Thanks in advance for any suggestions
Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top