LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Why does the date toggle between formats

Hi Ron,
I tried this without any luck. My dates are YYYY so I amended the code to
accomodate this.

The worksheet runs the normal macro on each update so this must have
resulted on cell changes because it went into a loop. Interesting, but too
much for me.

It looks I'll have to make sure that the original macro is only run once
(99.9% of the time). Othewise, I can run thrice to force the toogle back to
dd/mm/yyyy.

Cheers
--
Jim


"Ron Rosenfeld" wrote:

On Mon, 29 Oct 2007 22:01:00 -0700, Jim G
wrote:

Hi Ron,

My regional settings are set to d/m/y format.

I deduced from OssieMac's reply that the dates in dd.mm.yy format are text
generated by the accounting system as you suggest. However, a formula that
uses the dates needs the macro to convert 12.09.07 to 12/09/07 otherwise it
remains as text and the formula returns 00/01/1900.

When the accounting system generated the dates as per the regional default,
for some inexplicable reason rows 490 to 495 (for example) out of 1800 rows
changed to US date format. Thus began my quest for a workaround.

--
Jim


Jim,

OK, two points.

Just to make sure we're talking about the same thing, when I write "regional
settings", I am talking about the settings one sees going through Control
Panel, and not settings within Excel. I still suspect some discrepancy in
formatting, with Excel seeing certain output from Accounting as Text, and other
output as true dates.

Second, instead of using the Text-to-columns wizard to do the conversion, why
not try doing the conversion differently and directly.

Assuming ALL of the data comes out of the accounting package as dd.mm.yy,
perhaps something like this would work better:

================================
Option Explicit
Sub DateConvert()
Dim rData As Range
Dim c As Range

'set rData to include all the cells with date info
'or you could test that certain patterns exist
Set rData = [A1:A100]
For Each c In rData
c.NumberFormat = "dd.mm.yy"
If c.Text Like "##.##.##" Then
c.Value = DateSerial(Right(c.Text, 2) + 2000, _
Mid(c.Text, 4, 2), Left(c.Text, 2))
End If
Next c
End Sub
==============================

The c.NumberFormat line is to take care of an issue where the date might have
been coerced by Excel into something else.
--ron



 
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
Date Formats david d Excel Discussion (Misc queries) 2 September 14th 08 12:29 PM
Dealing with date formats on expiration date bliten_bsas Excel Programming 1 October 4th 07 08:47 PM
Date Formats Amy Excel Discussion (Misc queries) 2 January 23rd 07 05:05 AM
date formats Matt Excel Discussion (Misc queries) 2 May 17th 06 07:52 AM
Date formats Hervinder Excel Discussion (Misc queries) 3 April 19th 06 01:22 PM


All times are GMT +1. The time now is 01:04 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"