Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code to have User input data for cell Bean Counter[_2_] Excel Discussion (Misc queries) 0 May 27th 10 09:56 PM
Prompt user to input data (pop-up box) Shags Excel Discussion (Misc queries) 2 January 13th 09 06:05 AM
Data Validation of user input Dan[_7_] Excel Worksheet Functions 1 April 29th 08 12:42 PM
User Data Input DRANDON Excel Worksheet Functions 0 June 30th 06 08:12 PM
Asking for user input if there is no data for the function elitewolverine Excel Worksheet Functions 0 October 13th 05 09:17 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"