Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jun 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Using "or" in VBA for Excel 2007

    Hi once again to all the boffins.

    In my worksheet, I have 4 named ranges: PL_CM_1, PL_CM_2, PL_CM_3, and PL_CM_4.

    If the value of any of these is "Yes", I want to have a message box appear.

    I could put the following in a cell:

    =IF(OR(PL_CM_1="Yes",PL_CM_2="Yes",PL_CM_3="Yes",P L_CM_4="Yes"),"Yes","No")

    and refer to that cell in my code, but is there an easier way to just refer to the named ranges?

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,895
    Thanks
    0
    Thanked 85 Times in 81 Posts
    Code:
    If [PL_CM_1] = "Yes" Or [PL_CM_2] = "Yes" or [PL_CM_3] = "Yes" or [PL_CM_4] = "Yes" Then
       msgbox "one or more of them is yes"
    End If
    for example.
    Regards,
    Rory
    Microsoft MVP - Excel.

  4. #3
    Star Lounger
    Join Date
    Jun 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks

Posting Permissions

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