Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ************ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2002 date entry: Cannot get away from d-m-yy entry format | Excel Discussion (Misc queries) | |||
DATE SCRIPT / add function col A, | Excel Discussion (Misc queries) | |||
script for date and currency formating | Excel Discussion (Misc queries) | |||
Auto Date Script.. | Excel Discussion (Misc queries) | |||
auto date script for 2 columns? have 1.. | Excel Discussion (Misc queries) |