Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclude/highlight names in a range (2003 SP2)

    Good morning

    I am trying to build an insurance calculator for the office, I have a range, ISOCountry, which is a list of 249 Country names which I select using data validation on another worksheet. Our insurance company have a few Countries that we must notify them of first before accepting a job for insurance, can I either

    1. adapt the data validation to give an error message if one of these particular Countries is selected, or
    2. in the next cell have something like the =IF(A1,"Afghanistan","Albania","Azerbaijan", etc. ) Then "Call for Confirmation"

    Hope that makes sense

    Cheers

    Steve
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Exclude/highlight names in a range (2003 SP2)

    Validation uses only one list, so you can't have it make an exception for some items within the validation list.
    I would create a second range named Confirm that contains a list of the countries for which confirmation is needed.
    You can then use one or more of the following:

    1) Use conditional formatting to highlight the cell with the country. You'd use a formula like this:
    <code>
    =NOT(ISERROR(MATCH(A1,Confirm,0)))
    </code>
    and specify the formatting you like.

    2) Use a formula in the next cell similar to
    <code>
    =IF(ISERROR(MATCH(A1,Confirm,0)),"","Call for confirmation!")
    </code>
    3) Use code in the On Change event of the worksheet to check for a match, and display a warning message if necessary.
    <code>
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim oCell As Range
    If Not Intersect(Range("A1:A100"), Target) Is Nothing Then
    For Each oCell In Intersect(Range("A1:A100"), Target).Cells
    If Not Range("Confirm").Find(What:=oCell.Value, LookIn:=xlValues, LookAt:=xlWhole) Is Nothing Then
    MsgBox "Confirmation needed for " & oCell.Value, vbExclamation
    End If
    Next oCell
    End If
    End Sub
    </code>
    Adjust the range as needed.

  3. #3
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Exclude/highlight names in a range (2003 SP2)

    Thanks Hans

    I am experimenting with option 2 which seems fine for my requirement

    Cheers

    Steve
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

Posting Permissions

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