+ Reply to Thread
Results 1 to 8 of 8

cell format: only numbers (no date) with any amount of decimals

  1. #1
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    cell format: only numbers (no date) with any amount of decimals

    Hi,
    I need a cell to restrict the input:
    -Only numbers are allowed.
    -No date posible.
    -Any amount of decimals (they must all be shown in the cell).

    I tried using the data validation and using the IsNumber() to restrict any non numeral input. The problem with this approach is that if the user enters a date; it apprears as a date format (eg: "5.May"). I'm using an european excel, where the decimal separator is a comma instead of a point; so if a user accidentaly types "5.5" instead of "5,5"; the cell will show "5.May".

    I also tried the cell format/number/number format. The problem in here is that I dont know how many decimal positions will the input number have; and I need them all to be shown.

    Is there any way to accomplish this?

    P.S. Unfortunatelly I am not allowd to use macros to solve this issue.

    Thanks a million.
    Last edited by Wizz; 09-08-2009 at 06:02 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: cell format: only numbers (no date) with any amount of decimals

    You say no dates are allowed but isn't there an inherent problem insofar as every whole number >=0 is both a valid number and a date
    (assumes 1900 date system in place)

  3. #3
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    Re: cell format: only numbers (no date) with any amount of decimals

    I guess it is.
    What I mean with "no date" is that the number should appear exactly as it was input; never change to Date format. If the user inputs "1234"; it should appear "1234" in the cell and never "18 May 09" nor "18.05.1903" nor any date format. As long as the numbers have no decimal places, everything works fine.
    My problem is when a user inputs a value with a point ("."). In a US excel, when the user inputs "5.5" excel interprets it as 5 units and 5 decimals. As my excel is in german, excel interprets it as 5th day of the 5th month of the current year and automaticly transforms it to date format (Asuming the cell was formates as "Standard"). I would like that in that case, excel does not allow the user to input that value (like the data validation does).

    Hope it is a bit more clear

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: cell format: only numbers (no date) with any amount of decimals

    Yes I understand - my point is there's no way of preventing user from entering 5.5 rather than 5,5 given both will be interpreted by XL as valid numbers (ie testing for presence of . in the source value won't work).

    What are the boundaries of the values to be entered by the user ... ie are you likely to exceed say 39814 (1st Jan 2009) - if not you can use this as the upper boundary - entering 5.5 would go as a date but into current year and would therefore be >= 39814, ie:

    =AND(ISNUMBER(A1);A1<39814)

    Still wouldn't prevent user from entering 1.1.5 though... but that's seemingly not an issue (ie it's an issue of decimal delimiter)

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: cell format: only numbers (no date) with any amount of decimals

    Hang on... perhaps you could use the format of the cell itself...

    Please Login or Register  to view this content.
    so the above tests both numeric and cell format remains General - if date is entered it will default to date format (ie <> "G") ... the General format should display the number as entered (ie to as many decimals as entered (or none if whole))

    (obviously you need to set format to General before applying the Validation rule!)

  6. #6
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    Re: cell format: only numbers (no date) with any amount of decimals

    AWESOME !!!
    Exactly what I needed.

    Just one more question. As I'm using a German version of excel, instead of "G" for general, I have to use "S" for Standard.
    Is there a index number for that "General"? so that regardles of the excel language, the CELL() formula allways compares to the General/Standard format?

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: cell format: only numbers (no date) with any amount of decimals

    Quote Originally Posted by Wizz View Post
    Is there a index number for that "General"? so that regardles of the excel language, the CELL() formula allways compares to the General/Standard format?
    In all honesty I don't know... what I can say is that there is no "S" format when running UK/US (the S(cientific) is otherwise always followed by decimal indicator, eg S0 so S won't be returned)... if there's no G format on your locale (check XL Help in your version) then you can perhaps adapt to:

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    Re: cell format: only numbers (no date) with any amount of decimals

    Its a little bit strange because even if in the F1 help, it states that the cell result should be "G", for General/Standard, the formula is retrieving a "S".

    But the "OR" solution is perfect.

    Thanks a million. It was very helpful.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1