+ Reply to Thread
Results 1 to 2 of 2

Validation based on data entry

  1. #1
    Registered User
    Join Date
    06-10-2009
    Location
    Cheshire
    MS-Off Ver
    Excel 2007
    Posts
    1

    Validation based on data entry

    I need to have 2 validation rules in my spreadsheet:

    In a cell within the range A3:A20 the user must type in a username either 7 or 8 characters (mixture letters and numbers) but must start with N or S or error displayed and user cannot proceed.

    When this cell has validated, on entering data into a cell within the range G3:G20, if the user has typed in a username in a cell within the range A3:A20 that starts with N, then they must type in a username starting with N and similarly if the username starts with S, this also needs to start with S.

    I've written an if else statement but would be grateful for any help. Hope this makes sense.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    If (Left(A3, 1) = "N") Then
    response1 = MsgBox("username must start with N", vbOKOnly)
    ElseIf (Left(A3, 1) = "S") Then
    response2 = MsgBox("username must start with S", vbOKOnly)
    End If
    End Sub

  2. #2
    Forum Contributor starryknight64's Avatar
    Join Date
    09-27-2006
    Location
    Missouri
    MS-Off Ver
    2003 (Work) & 2007 (Home)
    Posts
    193

    Re: Validation based on data entry

    Try this out:

    Please Login or Register  to view this content.
    I hope this helps!
    starryknight64

+ 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