Forum Discussion
Change date format.
Hi again and thanks for your answer
from;
Subodh_Tiwari_sktneer (Valued Contributor) mentioned you in a post! Join the conversation below:
First of all the common =ISNUMBER(A1), in Norwegian ERNUM (A1), returns #NAVN? probably (#NAME?), Not true or False.
When I tried the Function "Text to Colums" it work only when i tried a singel cell. With multiply cells.. -Excel returns "the function do not work in multiply cells".
So I'm still stuck to return that date format from yyyy.mm.dd to dd.mm.yyyy still.
Is there any more solutions to change multiply date cells?
The best from
Lars Gunnar
Can you please upload a sample workbook to see how your data is organized on the sheet?
You actually didn't reply the following question.
What date separator do you use as per your regional settings? Is it a dot (period)?
- larsgunnar007Mar 20, 2020Copper Contributor
Of course.
I mark the Row green where I want do change the datoformat all-in-one operation. An put it in the attached macro.
Yes I separate with dot (.)
ExchangeConverter.xlsm Attached.
I'm exited to hear your solution.
Sincerely
Lars Gunnar
- Subodh_Tiwari_sktneerMar 20, 2020Silver Contributor
Please give the following code a try which may or may not work as dates are tricky to handle.
My default date format is mm/dd/yyyy and changed it to mm.dd.yyyy to test the code for you and it worked on my end but not sure how this would work on your end.
Insert a New Module say Module2 and place the codes given below on to Module2 and run the code ConvertToDates. The code will prompt you to select the Date cells and you should select the green cells with dates and press OK to continue.
After code is run, let me know if the code converts all the dates into the real dates.
Dim dtFound As Boolean Sub ConvertToDates() Dim Rng As Range Dim Cel As Range On Error Resume Next Set Rng = Application.InputBox("Please select the Cells with Date in them.", "Convert Date String Into Real Date!", Type:=8) On Error GoTo 0 Application.ScreenUpdating = False If Rng Is Nothing Then MsgBox "You didn't select the Date Cells!", vbExclamation Exit Sub End If For Each Cel In Rng Cel.Value = DateStringToDate(Cel.Text) If dtFound Then Cel.TextToColumns Destination:=Cel dtFound = False End If Next Cel Rng.NumberFormat = "dd.mm.yyyy" Application.ScreenUpdating = True End Sub Function DateStringToDate(ByVal str As String) Dim Matches As Object Dim y As Long Dim m As Long Dim d As Long With CreateObject("VBScript.RegExp") .Global = False .Pattern = "(\d{4})\.(\d{2})\.(\d{2})" If .Test(str) Then dtFound = True Set Matches = .Execute(str) y = Matches(0).SubMatches(0) m = Matches(0).SubMatches(1) d = Matches(0).SubMatches(2) DateStringToDate = DateSerial(y, m, d) Else DateStringToDate = str End If End With End FunctionIn the attached, I have placed the code on Module2 for you to test.
- larsgunnar007Mar 23, 2020Copper Contributor
Hi again.
I think this is a kind of bug or fault in Excel.
I followed your advice looked into the CP the short format who was like this dd.MM.YYYY and long like dddd d. MMMM YYYY.
I tried to change to small letters like dd.mm.yyyy and dddd d.mmmm yyyy but W10 returned "one or several of the letters you tried are invalid..." ..so i had to use the letters as shown above. That is also the format I want.
I also tried other formats but still the format return original from the imported source.
What I can say is that here must MS make a change in Excel or make a command who clean Cells from invisible characters without without deleting the cell content. I'm convinced that it is these characters who make the challenge here.
When I google this, i can see that someone import the data into Notebook and restore it in Excel. That's not a good solution I thing. So I beg you to come up with something who "walk around" this fault in Excel.
Thank you so far.
Sincerely
Lars Gunnar