LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default How to give the numberformat the systemdefault date format?

My guess is that you are overcomplicating something that would take
care of itself if you used.
aValues(1) = DateSerial(2000,2,10)

are you saying that #2/10/2000# as a date constant in VBA is not
US centric. Anyway the use of Date function is unambibuous and
should result in your own regional formatting if the formatting is General
to begin with.. As you know Excel will change the defaulted format
when the Regional Settings change.

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"ajd" wrote in message ...
Hi All,

How can I format some cells use the system default date format in Excel ?
So that when the regional settings in Windows changes, the date format will
be also changed accordingly.

Although without numberFormat does excel function automatically, however
here we have an array, I have to assign the numberFormat because of the
other cells.

A code expamle is listed as following: Thanks in advance.

Zuxiang DAI


sub doIt()

Dim aValues(0 To 1) As Variant
Dim aFormats(0 To 1) As String

aValues(0) = "000100.123456000"
aFormats(0) = "@"


aValues(1) = #2/10/2006#

'how can I tell excel this should be a system default date format?
aFormats(1) = ????????

Application.ErrorCheckingOptions.NumberAsText = False

Range("A1", "B1").numberFormat = aFormats
Range("A1", "B1").Value = aValues

End Sub





 
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 to look at current date and markdown date to give price veena Excel Discussion (Misc queries) 4 November 13th 08 07:40 PM
Format numberformat Single BenCoo Excel Worksheet Functions 1 March 17th 06 06:17 PM
NumberFormat e date Francesco Geri Excel Programming 3 October 21st 05 02:20 PM
A VBA function to give serial date for date and time? Android[_2_] Excel Programming 6 July 8th 04 03:55 PM
Cell Date/Time and NumberFormat issue Paul Excel Programming 1 December 16th 03 12:14 AM


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

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

About Us

"It's about Microsoft Excel"