S
StargateFanFromWork
I modified some code kindly given to me this week, trying
to see what I could come up with. User input is
completely new to me so I'm shaky. I've studied the
syntax in the VB help for inputbox but I'm stumped and
code examples for inputbox that I've pulled up with google
haven't yielded anything I can work with. This is quite a
bit more straightforward that some of the code I've seen
<lol>.
Here is the muddle I've made of the given code <g>:
Sub Test()
Dim vResponse As Variant
Do
vResponse = Application.InputBox( _
Prompt:="Enter overtime start date
(i.e., 01 for January, 02 for February, etc.):", _
Title:="Overtime Start Date", _
Default:=Format(Date, "mmm"), _
Type:=2)
If vResponse = False Then Exit Sub 'User cancelled
Loop Until IsDate(vResponse)
Range("AB2").Value = CDate(vResponse)
End Sub
Actually, just changed a couple of things. What I do like
about the above is that it shows "May" as the default
which the user can overwrite. I initially thought that
there might have to be two requests for info for the month
and then the date, but ideally, it would be even better if
the user could input just today's date, say 12/05/2005,
and that Excel would take the "05" for May and put "May"
as text in cell AB2 and then that it would take the date
of "12" and just dumps a "12" in B16. That would be the
ideal, but I'll go with best syntax that is still
efficient. The reason I'd like to automate this for the
employees is due to the fact that the sheet is extremely
cumbersome to work with as it is, and it's quite large.
This way, the users will have a starting point and the
vital month and overtime start date will already be input,
and then the employee can continue from there.
Thanks much. D
to see what I could come up with. User input is
completely new to me so I'm shaky. I've studied the
syntax in the VB help for inputbox but I'm stumped and
code examples for inputbox that I've pulled up with google
haven't yielded anything I can work with. This is quite a
bit more straightforward that some of the code I've seen
<lol>.
Here is the muddle I've made of the given code <g>:
Sub Test()
Dim vResponse As Variant
Do
vResponse = Application.InputBox( _
Prompt:="Enter overtime start date
(i.e., 01 for January, 02 for February, etc.):", _
Title:="Overtime Start Date", _
Default:=Format(Date, "mmm"), _
Type:=2)
If vResponse = False Then Exit Sub 'User cancelled
Loop Until IsDate(vResponse)
Range("AB2").Value = CDate(vResponse)
End Sub
Actually, just changed a couple of things. What I do like
about the above is that it shows "May" as the default
which the user can overwrite. I initially thought that
there might have to be two requests for info for the month
and then the date, but ideally, it would be even better if
the user could input just today's date, say 12/05/2005,
and that Excel would take the "05" for May and put "May"
as text in cell AB2 and then that it would take the date
of "12" and just dumps a "12" in B16. That would be the
ideal, but I'll go with best syntax that is still
efficient. The reason I'd like to automate this for the
employees is due to the fact that the sheet is extremely
cumbersome to work with as it is, and it's quite large.
This way, the users will have a starting point and the
vital month and overtime start date will already be input,
and then the employee can continue from there.
Thanks much. D