+ Reply to Thread
Results 1 to 6 of 6

use of If Function with Or Function

  1. #1
    Registered User
    Join Date
    08-06-2021
    Location
    India
    MS-Off Ver
    2016
    Posts
    2

    use of If Function with Or Function

    HELP ME
    I want to use more than one condition in Left(Cells(1, 1), 2) <> "HE". e.g., here I have used "HE" but I want to use "SE" along with "HE" and I have used Or function but it is giving an error, please help!!

    Below is my code:


    Please Login or Register  to view this content.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,348

    Re: use of If Function with Or Function

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new, I have done it for you today.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,086

    Re: use of If Function with Or Function

    This
    Please Login or Register  to view this content.
    needs to be
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    08-06-2021
    Location
    India
    MS-Off Ver
    2016
    Posts
    2

    Re: use of If Function with Or Function

    Thank you, It worked
    quick follow up question, if I want to use many letters, e.g. "HE" "SE" "IN" "US" "RA" "UK", then this code will become too big.
    Is there any short code or any shortcut?

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: use of If Function with Or Function

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,891

    Re: use of If Function with Or Function

    Try this:
    PHP Code: 
    Sub test()

    Dim a As String

    Left(Cells(11), 2)

    If 
    InStr("HE|SE|IN|US|RA|UK"a) = 0 Then MsgBox ("Condition Is True") Else MsgBox ("Condition Is False")

    End Sub 

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Right function, Left function, Mid function to extract values in column A
    By bjnockle in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 06-14-2020, 03:14 PM
  2. Replies: 0
    Last Post: 07-07-2018, 04:13 AM
  3. COUNTUNIQUE Function in Google Sheets; Excel lacks a direct counterpart to this function?
    By PivotTablePSHomage in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2018, 05:27 AM
  4. Calling function inside function. (aka nested function)
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2015, 05:58 AM
  5. VBA code for custom function that returns detail results of array function
    By onechipshot in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2015, 06:30 PM
  6. Replies: 13
    Last Post: 04-08-2014, 05:46 AM
  7. Replies: 1
    Last Post: 03-21-2012, 11:22 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1