Re: macro in word table by Jezebel
Jezebel
Mon Feb 21 17:25:31 CST 2005
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.
"davidm" <davidm@discussions.microsoft.com> wrote in message
news:574192DC-321E-443A-BE1A-735F6D5F981C@microsoft.com...
>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
>