Results 1 to 10 of 12

Thread: How To Avoid Using Too Many OR and AND Functions In VBA

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    You could do something like this

    Code:
    If Instr(1,"|2001|2002|2003|2011|2012|2017", "|" & ShD.Cells(C.Row, intYearCol).Value & "|") >0 Then
    'Your other code
    End if
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  2. #2
    Junior Member
    Join Date
    Nov 2017
    Posts
    21
    Rep Power
    0
    Quote Originally Posted by Excel Fox View Post
    You could do something like this

    Code:
    If Instr(1,"|2001|2002|2003|2011|2012|2017", "|" & ShD.Cells(C.Row, intYearCol).Value & "|") >0 Then
    'Your other code
    End if

    WOW!

    Admin you are amazing!

    it works.

    thanks so much

  3. #3
    Junior Member
    Join Date
    Nov 2017
    Posts
    21
    Rep Power
    0
    to make it work. i added one extra vertical bracket If Instr(1,"|2001|2002|2003|2011|2012|2017|", "|" & ShD.Cells(C.Row, intYearCol).Value & "|") >0 Then

    thanks alot


    if this is the one to include

    what could be the opposite of this.
    for example

    i would say exclude "|1998|1995|1992|1978|1983|1977|"

    is it something like i use Not or there is another trick for excluding?

    thanks Admin

Similar Threads

  1. Color Functions In Excel
    By Admin in forum Download Center
    Replies: 2
    Last Post: 10-24-2013, 11:44 AM
  2. VBA Trick of the Week :: Avoid Loop for Range Calculations - Evaluate
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 06-18-2013, 11:42 PM
  3. Declaring API Functions In 64 Bit
    By marreco in forum Excel Help
    Replies: 2
    Last Post: 02-11-2013, 03:18 AM
  4. VBA to avoid - "indirect" Formula
    By leopaulc in forum Excel Help
    Replies: 2
    Last Post: 10-23-2012, 05:01 PM
  5. Avoid flickering in excel
    By Excelfun in forum Excel Help
    Replies: 3
    Last Post: 05-17-2012, 09:37 AM

Tags for this Thread

Posting Permissions

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