Home |
Search |
Today's Posts |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
RunDate = Dim RunDate(0 To 25) As Date
MyNum = Dim MyNum As Long You need more? "Dave Peterson" wrote: Where did you get MyNum? Nils Titley wrote: Ron, I confess, I don't know how to get the numeric value of it? "Ron Rosenfeld" wrote: On Sun, 23 Mar 2008 00:52:04 -0700, Nils Titley wrote: Thanks to all for responding but I am wondering. Will I have a problem with 12/02/08. This is not December 02,08 but it is Feb 12, 08. The dd/mm/yy has already caused a problem. The macro is being used in South Africa. I had to force format on a date because it was changing the format. The code below produced 02/12/08 when it is 12/02/08. It worked only after I changed below to Format(RunDate(MyNum), "dd/mm/yy") With ActiveCell.Offset(0, 0) .NumberFormat = "dd/mm/yy" .Value = RunDate(MyNum) .HorizontalAlignment = xlCenter How do I force the day of the week? Thanks , I hope I am making sense. I believe you may be misunderstanding how dates are being entered into Excel. Excel stores dates as serial numbers with 1 = 1 Jan 1900. It then formats that result depending on the cell format. However, a date expressed like 12/02/08 is ambiguous. So when you enter that value into a cell, Excel has to decide if you mean 12 Feb or 2 Dec. It does this by looking at the date settings -- NOT in Excel -- but at Control Panel/Regional and Language Options. So if your code is producing 2 Dec when you expect it to be producing 12 Feb, you need to look at the output of RunDate(MyNum). If the numeric value is 39490, then it is returning 12 Feb; if 39784, then 2 Dec. If it is returning the desired date, then .numberformat = "dddd" will return the correct day of the week. --ron -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert regular Date to Week Ending or Week Beginning Dates | Excel Discussion (Misc queries) | |||
How do I convert a date to Monday's date within its week? | Excel Worksheet Functions | |||
Convert Week Number to Date | Excel Discussion (Misc queries) | |||
How do I convert a date to a week of the year? | Excel Discussion (Misc queries) | |||
How can I convert a date into a week number... | Excel Worksheet Functions |