+ Reply to Thread
Results 1 to 6 of 6

More Than One Data validation For the Same Cell

Hybrid View

cgi_pro More Than One Data validation... 11-11-2006, 09:25 AM
davesexcel Private Sub... 11-11-2006, 09:54 AM
mrice Response 11-11-2006, 09:55 AM
VBA Noob Hi, If you don't need a... 11-11-2006, 09:58 AM
cgi_pro Thanks VBA Noob, your way... 11-11-2006, 04:35 PM
VBA Noob Hi cgi_pro, Thanks for the... 11-11-2006, 04:39 PM
  1. #1
    Registered User
    Join Date
    02-12-2006
    Posts
    54

    More Than One Data validation For the Same Cell

    Hello

    How do I let a certain cell accept confined with two restrictions such as (text length = 7 and this text to be numeric)?

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
    
    
    If Not IsNumeric(Target) Then
        MsgBox "enter a number in cell A1"
        Range("A1").ClearContents
        Range("A1").Activate
        End If
        End If
               Dim LResult As Long
    
            LResult = Len(Target)
    If LResult > 7 Then
    MsgBox "No more then 7 digits , bonehead"
        Range("A1").ClearContents
        Range("A1").Activate
    
    
     End If
    End Sub
    this goes into your worksheet module, sets A1 as the target

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    You might need to use a macro triggered by the worksheet change event to test for this more complex criteria.
    Martin

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    If you don't need a macro then use this in Tools > Data Validation

    =AND(ISNUMBER(A1),LEN(A1)<=7)

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    02-12-2006
    Posts
    54
    Thanks VBA Noob, your way worked the best, and thanks a lot to the rest as well, they were very jelpful as well

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi cgi_pro,

    Thanks for the feedback.

    Glad I could help

    VBA Noob

+ 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