Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is the quickest way to make all the cells in defined range have the
number format (NumberFormat = "0") when they show the hash sign due to an incompatible value with the date format? These cells have values such as 18950315, which is an Interbase integer date format. After the format is changed to number these values will have to be converted to a string showing the date. All these values are pre Excel dates, but the problem is that they are intermixed with normal Excel compatible dates that are handled in a different way. I have code that does the job, but it is slightly slow: Sub ChangeHashesToDates(ByRef rng As Range, Optional ByVal strFormat As String = "") Dim c As Range Application.StatusBar = _ " Converting pre Excel dates, please wait ..." If strFormat = "" Then For Each c In rng If Len(c.Text) = 32 Then c.NumberFormat = "0" c.Text = Right(c.Value, 2) & "/" & _ Mid(c.Value, 5, 2) & "/" & _ Left(c.Value, 4) End If Next Else For Each c In rng If Len(c.Text) = 32 Then c.NumberFormat = "0" c = Format(DateSerial(Left(c, 4), _ Mid(c, 5, 2), _ Right(c, 2)), _ strFormat) End If Next End If End Sub Thanks for any advice. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert Date string to date format | Excel Discussion (Misc queries) | |||
Convert worksheet string name to date format in cell | Excel Worksheet Functions | |||
convert number to date format | Excel Discussion (Misc queries) | |||
convert a string of into a date format | Excel Programming |