ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date Entry Script (https://www.excelbanter.com/excel-programming/289663-date-entry-script.html)

Larry Townsend

Date Entry Script
 
I have the following Script I use in Lotus SmartSuite 9.5.
I am switching all my Scripts to Excel 2000.
I am done except for this one below.
I am stuck in the mud on this one. I enter "date number enter", "then month
number enter"
Help Please

Thank you
************
Sub GetDate
Dim userday As Integer
Dim usermonth As Integer
Dim useryear As Integer
usermonth% = Cint(Inputbox$("Enter the Month's Number."))
userday% = Cint(Inputbox$("Enter Day Number."))
.contents = Cstr(usermonth)&"/"&Cstr(userday)&"/"&Cstr(2004)
.FormatName = "31-Dec"
.TextHorizontalAlign = $AlignCenter
End Sub
************



Jim Cone

Date Entry Script
 
Larry,

The following code may do what you want.
(Depending on the country this is being used in,
the date format may have to be changed.)

'--------------------------------------------
Sub GetUserDate()
Dim UserDate As Variant

Retry:
UserDate = InputBox(vbNewLine & "Enter the date - Month/Day/Year", _
" Larry Townsend Asks You To...", Format$(Date, " MMM/DD/YYYY "))
On Error Resume Next
UserDate = CDate(UserDate)

If Err.Number < 0 Then
UserDate = MsgBox("Your entry is not a valid date. ", _
vbRetryCancel + vbExclamation, " OOPS")
If UserDate = vbCancel Then
Exit Sub
Else
Err.Clear
GoTo Retry
End If
End If

With ActiveSheet.Range("B4")
.NumberFormat = "DD-MMM"
.HorizontalAlignment = xlHAlignCenter
.Value = UserDate
End With
End Sub

'--------------------------------------------
Regards,
Jim Cone
San Francisco, CA

"Larry Townsend" wrote in message
...
I have the following Script I use in Lotus SmartSuite 9.5.
I am switching all my Scripts to Excel 2000.
I am done except for this one below.
I am stuck in the mud on this one. I enter "date number enter", "then month
number enter"
Help Please
Thank you
************
Sub GetDate
Dim userday As Integer
Dim usermonth As Integer
Dim useryear As Integer
usermonth% = Cint(Inputbox$("Enter the Month's Number."))
userday% = Cint(Inputbox$("Enter Day Number."))
.contents = Cstr(usermonth)&"/"&Cstr(userday)&"/"&Cstr(2004)
.FormatName = "31-Dec"
.TextHorizontalAlign = $AlignCenter
End Sub





All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com