loop to time in 24 hours format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I want to make a loop in time format

like from 9:00 to 16:00
and with every half hour like
9:00 - 9:30 - -10:00 - 10:30
can i do that ?

Regards alvin
 
Hi Alvin,

Could do that very easily manually -

A1: 09:00
A2: 10:00
select A1:A2
grab the little handle and drag down to A14
B2: =TEXT(A1,"hh.mm -") & TEXT(A2,"hh.mm")
double click the handle to fill down

maybe you prefer "h.mm" format

Or do you particularly need a VBA solution?

Regards,
Peter T
 
Alvin said:
Hi
I want to make a loop in time format

like from 9:00 to 16:00
and with every half hour like
9:00 - 9:30 - -10:00 - 10:30
can i do that ?

Regards alvin
Make a sub in ThisWorkbook with:

Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:30:00"), "RunThisSub"
End Sub


Create a module with:

Public dTime As Date
Sub RunThisSub()
dTime = Now + TimeValue("00:30:00")
Application.OnTime dTime, "RunThisSub"

If Time < "09:00:00" or Time > "16:00:00" then exit sub

'Put your code here

End Sub


This wil run every half hour but wil exit if not between 9 and 16 hours
 
You mean something like this:
Sub Tester1()
Dim i As Single
For i = #9:00:00 AM# To #4:00:00 PM# Step #12:30:00 AM#
Debug.Print Format(i, "hh:mm:ss")
Next
End Sub
 
Seeing Warzel's adjacent post, I realize I completely misunderstood the
question. Ignore my suggestion.

Peter T
 

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

Back
Top