I am trying to write a macro that will ask the user to input a start time.
This time is in 12 hour time. The macro needs to add 15 minutes and then
paste the time range together in one cell. How do I get it to do this? It
should look like this, input time is 3:15, then add 15 minutes to get 3:30.
Then paste them in the cell like this 3:15-3:30. If anyone can help that
would be great.
Thanks,
David
Jezebel - 21 Feb 2005 23:25 GMT
Dim pStart as date
Dim pEnd as date
pStart = cdate(inputbox("Enter the start time"))
pEnd = DateAdd("n", 15, pStart)
Selection.TypeText Format$(pStart, "H:nn") & "-" & format$(pEnd, "H:nn")
You might want to get more sophisticated with the input part -- as it is the
code will fail if the user cancel or enters an invalid date/time.
In place of the Selection.TypeText you might want something like
ActiveDocument.Tables(1).Cell(3,4).Range = ... or wherever you need the
result to end up.
>I am trying to write a macro that will ask the user to input a start time.
> This time is in 12 hour time. The macro needs to add 15 minutes and then
[quoted text clipped - 5 lines]
> Thanks,
> David