Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Validation No Blanks (XL2K)

    I am trying to validate a lookup table so that it has to have numbers in it. Zero values are acceptable but blanks are not as they break formulas further on in the spreadsheet.

    I have tried setting the validation to Number and Greater than or Equal to 0 and deselecting the ignore blanks but it still allows the blanks.

    Many thanks for any pointers

    Peter

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Validation No Blanks (XL2K)

    I don't think that data valadation can be used for this. The Code below, placed in the worksheet change event routine, will insure that cells A1:A100 on that worksheet can only be changed to a numeric value.

    <pre>Private Sub Worksheet_Change(ByVal Target As Range)
    Dim oCell As Range
    If Intersect(Target, ActiveSheet.Range("A1:A100")) Is Nothing Then Exit Sub
    For Each oCell In Intersect(Target, ActiveSheet.Range("A1:A100"))
    If (Not IsNumeric(oCell.Value)) Or oCell.Value = "" Then
    Intersect(Target, ActiveSheet.Range("A1:A100")).Select
    MsgBox "Cells must contain numeric value."
    Exit Sub
    End If
    Next oCell
    End Sub
    </pre>

    Legare Coleman

  3. #3
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Trenton, Ontario
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Validation No Blanks (XL2K)

    When you open up the validation on the right hand side there is a check box that says "Ignore Blanks". The default is for it to be checked, uncheck it and see what happens.

    Stats

  4. #4
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Validation No Blanks (XL2K)

    Thanks for the code Legare.
    On further investigation it was not the blanks that was breaking my formulas anyway <img src=/S/blush.gif border=0 alt=blush width=15 height=15> Still it seems strange that "Ignore Blanks" seems to make no difference when specifying numbers only!

    Peter

Posting Permissions

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