Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Loop through time values in 30 min increments 1

Status
Not open for further replies.

JasonEnsor

Programmer
Sep 14, 2010
193
GB
Hi Guys,

I am building a userform to deal with creating a rota. What I am wanting to do is let the user select a start and end time from a dropdown list then when they click a button it will populate the worksheet as follows

Person 1 start time = 08:00 end time = 09:00
Person 2 start time = 08:00 end time = 10:00

Columns Headings (these are times)
_______|08:00 | 08:30 | 09:00 | 09:30 | 10:00 | 10:30
Person 1|A | A | | | |
Person 2|A | A | A | A | |

What I am wanting to do is loop through the people then populate the worksheet for each 30 min time increment between the start and end time. My issue is I am not sure of loop through the times in 30 increments

So for person 2 I would have a loop like

Code:
starttime = "08:00"
endtime = "10:00"

time = starttime 

while time not equal to endtime
   ' do code here to populate the sheet etc...
   time + 30mins
Loop

Does anyone out there have any tips on how to achieve the looping through the time?

Many Thanks in advance

J.


Regards

J.
 
Hi,

time is not a good variable, but...
Code:
time = time + TimeSerial(0,30,0)

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
...also...
Code:
while time < endtime

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Cheers Skip,

Once again you have saved the day.

Many Thanks

J.

Regards

J.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top