VBA EXCEL - NUMBERFORMAT didn´t work but FORMAT FUNCTION did
10,729
"The Format function uses different format code strings than do the NumberFormat and NumberFormatLocal properties." from http://msdn.microsoft.com/en-us/library/office/aa224873%28v=office.11%29.aspx.
Author by
Gera
Updated on September 12, 2022Comments
-
Gera over 1 year
I have a range of cells named MyCells as string type. In which there are strings with 26 digits.
Why the first statement (below), with NumberFormat didn´t work, but the second did?
Trying cells look like this:
38935094000163001000052234 --> 38.935.094/0001-63 001 000052234
First attempt (didn´t work):
range(MyCells).Select Selection.NumberFormat = "00"".""000"".""000""/""0000""-""00"" ""000"" ""000000000"
Second (successful):
range(MyCells).Select For Each c In Selection c = Format(c, "00"".""000"".""000""/""0000""-""00"" ""000"" ""000000000") Next