Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input Data from user in correct Format
I would like to be able to prompt the user to enter a date and place this
information in a cell (with a number format which has category Custom and Type "dd/mm/yyyy" . I tried the following code, however if the user enters 7/2/05 it will appear in the cell as 2/7/05: Message = "Enter the start date for the report" Title = "Start Date" Default = "7/2/05" StartDate = InputBox(Message, Title, Default) Sheets("Weekly").Select Range("G5").Select ActiveCell.NumberFormat = "dd/mm/yyyy" ActiveCell.FormulaR1C1 = StartDate Any suggestions as to how to fix this would be much appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input Data from user in correct Format
Dim dtStart as Date, Message as String, Title as String
Dim StartDate as String Message = "Enter the start date for the report" Title = "Start Date" Default = "7/2/05" StartDate = InputBox(Message, Title, Default) If isdate(StartDate) then dtStart = cDate(StartDate) With Sheets("Weekly").Range("G5") .NumberFormat = "dd/mm/yyyy" .Value = dtStart End With Else msgbox "This is not a valid date" End if -- Regards, Tom Ogilvy "Tricia" wrote in message ... I would like to be able to prompt the user to enter a date and place this information in a cell (with a number format which has category Custom and Type "dd/mm/yyyy" . I tried the following code, however if the user enters 7/2/05 it will appear in the cell as 2/7/05: Message = "Enter the start date for the report" Title = "Start Date" Default = "7/2/05" StartDate = InputBox(Message, Title, Default) Sheets("Weekly").Select Range("G5").Select ActiveCell.NumberFormat = "dd/mm/yyyy" ActiveCell.FormulaR1C1 = StartDate Any suggestions as to how to fix this would be much appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA Code to have User input data for cell | Excel Discussion (Misc queries) | |||
Prompt user to input data (pop-up box) | Excel Discussion (Misc queries) | |||
Data Validation of user input | Excel Worksheet Functions | |||
User Data Input | Excel Worksheet Functions | |||
Asking for user input if there is no data for the function | Excel Worksheet Functions |