View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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