Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
REPLACE command drops leading zeros Guy Kerr Excel Discussion (Misc queries) 5 April 4th 23 12:40 PM
Using REPLACE command removes leading zeros Guy Kerr Excel Discussion (Misc queries) 2 October 15th 09 05:23 PM
how do I remove leading spaces and leave the remianing spaces w Debi Excel Worksheet Functions 6 February 28th 07 03:29 PM
How do I add leading spaces to a value? Chris Brown Excel Worksheet Functions 3 March 3rd 06 05:23 PM
save text field w/ leading zeros in .csv format & not lose zeros? Ques Excel Discussion (Misc queries) 1 May 4th 05 06:21 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"