Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Format Cells

=TEXT(A1,IF(ISNUMBER(FIND(".",A1)),REPLACE(REPT("0 ",LEN(TRIM(A1))),FIND(".",TRIM(A1)&"."),1,"."),REP T("0",LEN(TRIM(A1)))))

I have an excel function to get number value from text formatted cells
But sometimes it has 1/2 like values in cells. Then the output value
displays like 39479
Is there any way to avoid this?
Pls Help..


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Format Cells

When you have the text 1/2 (not .5 and not Jan 2), you're formula boils down to:

=text("1/2","000")

And =text() is one of those "forgiving" functions.

If the first argument looks like a number, then excel will treat it like a
number. And in your case, excel "sees" a special number--a date (January 2 of
the current year (2008)).

So excel returns the serial number for that date: 39449 (and =text() returns it
as text (not a number).

So you could avoid the problem by looking to see if the cell is numeric or text
first:

=if(istext(a1),"it's text",yourlongformulahere)

But I don't have a guess how you would want "1/2" treated.



Marc wrote:

=TEXT(A1,IF(ISNUMBER(FIND(".",A1)),REPLACE(REPT("0 ",LEN(TRIM(A1))),FIND(".",TRIM(A1)&"."),1,"."),REP T("0",LEN(TRIM(A1)))))

I have an excel function to get number value from text formatted cells
But sometimes it has 1/2 like values in cells. Then the output value
displays like 39479
Is there any way to avoid this?
Pls Help..


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Format Cells

Thanks Dave for your quick action

"Dave Peterson" wrote in message
...
When you have the text 1/2 (not .5 and not Jan 2), you're formula boils
down to:

=text("1/2","000")

And =text() is one of those "forgiving" functions.

If the first argument looks like a number, then excel will treat it like a
number. And in your case, excel "sees" a special number--a date (January
2 of
the current year (2008)).

So excel returns the serial number for that date: 39449 (and =text()
returns it
as text (not a number).

So you could avoid the problem by looking to see if the cell is numeric or
text
first:

=if(istext(a1),"it's text",yourlongformulahere)

But I don't have a guess how you would want "1/2" treated.



Marc wrote:

=TEXT(A1,IF(ISNUMBER(FIND(".",A1)),REPLACE(REPT("0 ",LEN(TRIM(A1))),FIND(".",TRIM(A1)&"."),1,"."),REP T("0",LEN(TRIM(A1)))))

I have an excel function to get number value from text formatted cells
But sometimes it has 1/2 like values in cells. Then the output value
displays like 39479
Is there any way to avoid this?
Pls Help..


--

Dave Peterson



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
Excel 2007 format cells to date format Stefan Excel Discussion (Misc queries) 0 June 1st 10 09:06 PM
How do I format cells to show date in Australian not US format? Kevin B[_2_] Excel Worksheet Functions 1 May 12th 08 04:17 AM
how do i format a cell based on format of a range of cells? Chris Hardick Excel Discussion (Misc queries) 2 April 3rd 06 08:54 AM
want format cells alignment not format cells font style Jeannie Bean Excel Discussion (Misc queries) 2 February 10th 06 09:31 AM
Cells won't convert to number format, even after format/cells/num. scottr Excel Discussion (Misc queries) 5 April 12th 05 11:02 PM


All times are GMT +1. The time now is 01:42 AM.

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"