It should be simple, but it's driving me crazy.
First of all, i'm brazilian and here standard date is dd/mm/yyyy.
Whenever excel gets the chance it autmatically formats my date as north american dates (mm/dd/yyyy)...
Example: 06/07/2016 turns 07/06/2016...
It happens in every first 12 days of a month, if the day can be a month it'll be changed.
I have dates that come from different origins, and one of them comes in "dd.mm.yyyy" format, the other "dd/mm/yyyy", and later i'll need to compare them... I'm trying to bypass the same problem in find and replace codes, wich besides alterig the first 12 days of a month to mm/dd/yyyy, it some times eats the zeros of months and days (it only doesnt work in code, when i use manual find and replace it's all good)
I tried .NumberFormat = "dd/mm/yyyy" and it still doesn't work.
I even tried splitting it like:
But it also converts to mm/dd/yyyy every first 12 days of a given month.
Now with this one I ALMOST get what I want.
After running it they're all date formats, they're all "on the same side of the cell" (left), and they're all dd/mm/yyyy format...
BUT... if i compare it with a regular date (the one that doesnt come with "."), it won't match, and excel will tell me they're different.... even if they have same format and look the same... maybe it's because i made them text first, but that's the only way i found to make them not get inverted...
how can I overcome this? Is there any settings to make "dd/mm/yyyy" standard date format?
note: if i take this last code (the one that almost works) and switch 'last line' with 'last but one' (see coments), i get to the same point where they're all date formated, but some (first 12 days) are mm/dd/yyyy and aligned with right border of cell, while others (the rest of dates) are dd/mm/yyyy and aligned with the left.
First of all, i'm brazilian and here standard date is dd/mm/yyyy.
Whenever excel gets the chance it autmatically formats my date as north american dates (mm/dd/yyyy)...
Example: 06/07/2016 turns 07/06/2016...
It happens in every first 12 days of a month, if the day can be a month it'll be changed.
I have dates that come from different origins, and one of them comes in "dd.mm.yyyy" format, the other "dd/mm/yyyy", and later i'll need to compare them... I'm trying to bypass the same problem in find and replace codes, wich besides alterig the first 12 days of a month to mm/dd/yyyy, it some times eats the zeros of months and days (it only doesnt work in code, when i use manual find and replace it's all good)
I tried .NumberFormat = "dd/mm/yyyy" and it still doesn't work.
I even tried splitting it like:
Code:
For Each c In Range(Range("C2"), Range("C2").End(xlDown))
f_day = Left(c, 2)
f_mth = Mid(c, 4, 2)
f_year = Right(c, 4)
c.Value = f_day & "/" & f_mth & "/" & f_year
Next c
Now with this one I ALMOST get what I want.
Code:
For Each c In Range(Range("C2"), Range("C2").End(xlDown))
c.NumberFormat = "@"
f_day = Left(c, 2)
f_mth = Mid(c, 4, 2)
f_year = Right(c, 4)
c.Value = f_day & "/" & f_mth & "/" & f_year
c.Value = Format(c.Value, "dd/mm/yyyy") 'last but one
c.NumberFormat = "dd/mm/yyyy" 'last line
Next c
BUT... if i compare it with a regular date (the one that doesnt come with "."), it won't match, and excel will tell me they're different.... even if they have same format and look the same... maybe it's because i made them text first, but that's the only way i found to make them not get inverted...
how can I overcome this? Is there any settings to make "dd/mm/yyyy" standard date format?
note: if i take this last code (the one that almost works) and switch 'last line' with 'last but one' (see coments), i get to the same point where they're all date formated, but some (first 12 days) are mm/dd/yyyy and aligned with right border of cell, while others (the rest of dates) are dd/mm/yyyy and aligned with the left.