ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Force a Number to be Formatted as Text (keep leading 0's) (https://www.excelbanter.com/excel-programming/305207-re-force-number-formatted-text-keep-leading-0s.html)

Tom Ogilvy

Force a Number to be Formatted as Text (keep leading 0's)
 
But if you had turned on the macro recorder and formatted a cell manually,
then turned it off and looked at the code you would have seen how to do it.
Just a reminder that the macro recorder does have its uses.

--
Regards,
Tom Ogilvy


"swaterhouse" wrote in message
...
Thanks, never would have guessed that and certainly couldn't find it in

any docs.
--
Scott


"Alex Guardiet" wrote:

Hi,

supposing G is the column you want to format, all you need is this line:

Columns("G:G").NumberFormat = "@"

Regards,

Alex

"swaterhouse" wrote:

I need to set a column so the formatting is set to "Text" even if the

value is numeric because the numeric value may have leading zeros that need
to be there. I have used the NumberFormat property on the Colums collection
to format numbers with specific numbers of decimals but cannot figure out
how to set it to text. I tried settimg the value with a leading space but
that didn't work.
--
Scott




sub_pop[_6_]

Force a Number to be Formatted as Text (keep leading 0's)
 
I have to do the same thing but rather than read as text, I...

variable = Format(variable, "0000000000")

Mar

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com