Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excluding Data (03)

    The following code works for departments equaling 88 or 99. How does one restate the code to include everything but department 88 or 99?

    I thought by placing a NOT in the line of code it would work but did not.

    If Range("R_Dept") = "88" Or Range("R_Dept") = "99" Then
    Run some code
    End If

    Thanks,
    John

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Excluding Data (03)

    Hi

    Have you tried

    If Range("R_Dept") <> "88" Or Range("R_Dept") <> "99" Then
    Run some code
    End If
    Jerry

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

    Re: Excluding Data (03)

    Jerry, your condition is always true! <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  4. #4
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excluding Data (03)

    I did but it still includes it.

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

    Re: Excluding Data (03)

    You'd also have to use parentheses, or use Not for both of them and change Or to And:

    If Not (Range("R_Dept") = "88" Or Range("R_Dept") = "99") Then

    or

    If Not Range("R_Dept") = "88" And Not Range("R_Dept") = "99" Then

  6. #6
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excluding Data (03)

    Hans,

    Your suggestion worked.

    Thank you,
    John

  7. #7
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Excluding Data (03)

    Whoops.... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Jerry

Posting Permissions

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