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. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,910
    Thanks
    0
    Thanked 89 Times in 85 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.

  3. #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
  •