+ Reply to Thread
Results 1 to 6 of 6

Data validation - accept "-" and numbers as input

  1. #1
    Registered User
    Join Date
    11-05-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    61

    Data validation - accept "-" and numbers as input

    Hi,

    i have a small data validation issue


    I need the cell to only accept "-" and whole numbers


    I will appriciate any help on this matter

    Thank you in advance
    Last edited by 2001jesper; 11-05-2013 at 07:09 AM.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Data validation - accept "-" and numbers as input

    Hi,

    Use a Custom Data Validation with this formula:

    =IF(ISNUMBER(A1),A1=INT(A1),A1="-")

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    11-05-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Data validation - accept "-" and numbers as input

    Perfect, work like a champ

    Thax

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Data validation - accept "-" and numbers as input

    Hi,

    Assuming the cell that you want to validate is cell G5, select G5 and then go to Data Validation --> Allow Custom --> enter this formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Broken down, this formula says that G5:
    1. Is exactly length 1 AND contains a "-" (and hence G5 is exactly a "-"); or
    2. The truncated value of G5 is the same as the value of G5 (thus allowing only whole numbers)

    NB: The IFERROR is required in the second argument of the OR function as a "-" results in a #VALUE error for this argument, which results in a #VALUE for the entire formula, resulting in the "-" not being allowed to be entered.

    Hope this helps

  5. #5
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Data validation - accept "-" and numbers as input

    Trumped me again XOR LX :P

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Data validation - accept "-" and numbers as input

    Haha! Sorry!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 10-23-2013, 05:20 PM
  2. [SOLVED] Data validation: allow entry into a cell if other three cells have "X", "Y" and "Z"?
    By RogerRangeRover in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-05-2013, 04:49 AM
  3. [SOLVED] Manually fill up 1 or (some) cells with just "BFW"or"BF" in data validation
    By robke1960 in forum Non English Excel
    Replies: 2
    Last Post: 12-11-2012, 11:31 AM
  4. [SOLVED] Userform to accept input from textbox after "return" is pressed
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2012, 06:59 AM
  5. Enter Data on "Main" or "Input" Sheet and Copy to One of Many Other Sheets
    By timothy_no7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2012, 07:29 PM

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