excel - Convert range formatted as date to text -
i have range of cells in date format, formatted dd.mm.yyyy
, this:
05.10.1993 05.10.1993 05.10.1993 05.10.1993
and want convert range of cells text format, using vba, without iterating each cell in range (as slow large range).
i used code:
set rsel = selection adate = rsel.value rsel.numberformat = "@" rsel.value = adate
so assign selected range intermediate array, convert range text format , assign array selected range.
result text:
5/10/1993 5/10/1993 5/10/1993 5/10/1993
and wonder did format conversion took place, if debug.print
example adate(1,1)
expected 05.10.1993
value? or how can instruct format in simple snippet posted expected text result?
in code, instead of adate=rsel.value
, try this:
adate = application.text(rsel.value2,rsel.numberformatlocal)
note
the following range properties relevant example:
.value
returns variant (number/date/string/boolean/error) dates in vba date format.
.value2
returns variant (number/string/boolean/error) dates converted serial numbers.
.text
returns string containing formatted value, applies individual cells only.
.numberformat
returns regional formats in format (eg entering 1/2/3 in cell gives m/d/yyyy)
.numberformatlocal
returns regional formats in local format (eg in european locale d/m/yy)
Comments
Post a Comment