Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to put mydate into activecell as dd/mm/yyyy excel 2007 vb

when using input box mydate and i try to put the date into the active cell it
changes from dd/mm/yyyy to mm/dd/yyyy how can stop this. Code follows

mydate = InputBox("Enter date as dd/mm/yyyy or Cancel to edit", Date, Date)
activecell=mydate
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default how to put mydate into activecell as dd/mm/yyyy excel 2007 vb

try activecell=format(mydate,"dd/mm/yyyy")

--

Gary
Excel 2003


"JohnnyP" wrote in message
...
when using input box mydate and i try to put the date into the active cell
it
changes from dd/mm/yyyy to mm/dd/yyyy how can stop this. Code follows

mydate = InputBox("Enter date as dd/mm/yyyy or Cancel to edit", Date,
Date)
activecell=mydate


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default how to put mydate into activecell as dd/mm/yyyy excel 2007 vb

probably better way to write this but as quick idea try following:

Sub DateAdd()
Dim MyDate As Date

On Error Resume Next

MyDate = InputBox("Enter date as dd/mm/yyyy or Cancel to edit", Date,
Date)

If MyDate = 0 Then
Exit Sub
Else
With ActiveCell
.NumberFormat = "dd/mm/yyyy"
.Value = MyDate
End With
End If
On Error GoTo 0
End Sub
--
jb


"JohnnyP" wrote:

when using input box mydate and i try to put the date into the active cell it
changes from dd/mm/yyyy to mm/dd/yyyy how can stop this. Code follows

mydate = InputBox("Enter date as dd/mm/yyyy or Cancel to edit", Date, Date)
activecell=mydate

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default how to put mydate into activecell as dd/mm/yyyy excel 2007 vb

I think that as long as you accept ambiguous date entries
(does 01/02/03 mean Jan 2, 2003 or Feb 1, 2003 or 2001-feb-03 or ...), then
you're going to have trouble with the way excel and the user's short date format
(under windows control panel) play together.

I think I'd ask for the date in a different way.

I think I'd use a userform with a calendar control (see Ron de Bruin's site):
http://www.rondebruin.nl/calendar.htm

Or even a userform with 3 different controls (day, month, year).


JohnnyP wrote:

when using input box mydate and i try to put the date into the active cell it
changes from dd/mm/yyyy to mm/dd/yyyy how can stop this. Code follows

mydate = InputBox("Enter date as dd/mm/yyyy or Cancel to edit", Date, Date)
activecell=mydate


--

Dave Peterson
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
Formula bar shows mm/dd/yyyy. To show dd/mm/yyyy. How? magna Excel Discussion (Misc queries) 2 January 1st 08 08:14 AM
how do I change date from mm/dd/yyyy to dd:mm:yyyy format in Excel Jack Wilson New Users to Excel 4 July 18th 06 01:57 PM
change birthday display from mm/dd/yyyy to HIDE the yyyy? johnp Excel Worksheet Functions 1 May 9th 06 09:56 PM
Macro formula using MYDATE not working Bricktop Excel Programming 2 October 27th 05 07:50 PM
opening excel file - date format problem: DD/MM/YYYY vs MM/DD/YYYY yung Excel Programming 2 March 18th 05 12:50 PM


All times are GMT +1. The time now is 04:50 AM.

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"