Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replace leading zeros with leading spaces ?
I am using Excel 2007.
Format (12,000) gives me 012 I want (12,??0) to be 12 with a leading space Question mark doesnt seem to work in Excel 2007 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replace leading zeros with leading spaces ?
Use this...
Format(12, "@@@") -- Rick (MVP - Excel) "Gary" wrote in message ... I am using Excel 2007. Format (12,000) gives me 012 I want (12,??0) to be 12 with a leading space Question mark doesnt seem to work in Excel 2007 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replace leading zeros with leading spaces ?
I need Format because this is part of a loop building a dynamic Message Box
that has several columns; I need the columns to be aligned for readability. Gary "Ryan H" wrote: I don't think you need to use Format. So you want "12" to look like " 12"? MyString = " 12" But I know if can't be that simple. Is "12" a value in a cell? If so, use this: MyString = " " & Range("A1").Value -- Cheers, Ryan "Gary" wrote: I am using Excel 2007. Format (12,000) gives me 012 I want (12,??0) to be 12 with a leading space Question mark doesnt seem to work in Excel 2007 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replace leading zeros with leading spaces ?
YES !!! That works .
Thanks, Gary "Rick Rothstein" wrote: Use this... Format(12, "@@@") -- Rick (MVP - Excel) "Gary" wrote in message ... I am using Excel 2007. Format (12,000) gives me 012 I want (12,??0) to be 12 with a leading space Question mark doesnt seem to work in Excel 2007 . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Replace leading zeros with leading spaces ?
You can also use
Val(your string here) For example, Val(0000012) = 12 -- Cheers, Ryan "Gary" wrote: I need Format because this is part of a loop building a dynamic Message Box that has several columns; I need the columns to be aligned for readability. Gary "Ryan H" wrote: I don't think you need to use Format. So you want "12" to look like " 12"? MyString = " 12" But I know if can't be that simple. Is "12" a value in a cell? If so, use this: MyString = " " & Range("A1").Value -- Cheers, Ryan "Gary" wrote: I am using Excel 2007. Format (12,000) gives me 012 I want (12,??0) to be 12 with a leading space Question mark doesnt seem to work in Excel 2007 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
REPLACE command drops leading zeros | Excel Discussion (Misc queries) | |||
Using REPLACE command removes leading zeros | Excel Discussion (Misc queries) | |||
how do I remove leading spaces and leave the remianing spaces w | Excel Worksheet Functions | |||
How do I add leading spaces to a value? | Excel Worksheet Functions | |||
save text field w/ leading zeros in .csv format & not lose zeros? | Excel Discussion (Misc queries) |