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
    Junior Member
    Join Date
    Nov 2017
    Posts
    21
    Rep Power
    0
    dear Administrator,

    how can i change this code that instead of hard coded values of "|2001|2002|2003|2011|2012|2017|" i used cell reference

    for example. my 2001 will be in cell A2 and 2002 will be in A3 and 2003 will be in cell A4 and so on.

    i tried this and it did not work If Instr(1,"A2:A7", "|" & ShD.Cells(C.Row, intYearCol).Value & "|") >0

    screenshot A
    E.png

    also how to i change the code if the values are in one cell separated by comma like screenshot B

    for the screenshot below i used If Instr(1,"A1", "|" & ShD.Cells(C.Row, intYearCol).Value & "|") >0 and it did not work.
    2017-11-24 15_39_07-Book1 - Excel.png
    Last edited by flora; 11-24-2017 at 07:41 PM. Reason: attached screenshot.

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    Also, wherever you are using code, can you please wrap it with the CODE tags. It increases readability.
    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

  3. #3
    Junior Member
    Join Date
    Nov 2017
    Posts
    21
    Rep Power
    0
    thank you very much Administrator.

    this excelfox is really the best.

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
  •