+ Reply to Thread
Results 1 to 4 of 4

Or function not operating as expected

Hybrid View

athyeh Or function not operating as... 08-06-2019, 06:17 AM
romperstomper Re: Or function not operating... 08-06-2019, 06:25 AM
athyeh Re: Or function not operating... 08-06-2019, 06:29 AM
romperstomper Re: Or function not operating... 08-06-2019, 06:33 AM
  1. #1
    Registered User
    Join Date
    06-12-2013
    Location
    Rochester, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    80

    Or function not operating as expected

    Hello,

    I have the following code:

    Do While Range("A1").value <> "Carrot" Or Not Range("A1").value Like "Apple*"
    sheet1.rows(1).delete
    Loop

    I want this to delete rows until the A1 says "Carrot" or "Apple Juice" but it keeps on deleting all rows no matter what value it is in. When viewed in isolation it works but not as an "Or" function so feel like there's something with the way I'm using "Or"? but usage seems congruent based on web examples.

    Thanks in advance,

    Tony
    Last edited by athyeh; 08-06-2019 at 06:25 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,137

    Re: Or function not operating as expected

    You want And, not Or. If A1 is Carrot, then Not A1 Like "Apple*" will be True, so Or would return True, and the code will carry on.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    06-12-2013
    Location
    Rochester, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Or function not operating as expected

    thank you very much.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,137

    Re: Or function not operating as expected

    Glad to help, and thanks for the rep.

+ 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. [SOLVED] getting expected array using the DIR function
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2019, 10:23 AM
  2. [SOLVED] IF function not working as expected
    By anande in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-30-2019, 12:29 AM
  3. Expected table is not in the expected format - ADODB Connection to Read Only Excel file
    By Roshan10043 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2018, 10:54 AM
  4. [SOLVED] Error: Expected Sub, Function, or Property
    By VAer in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-17-2017, 09:54 AM
  5. [SOLVED] IF function not performing as expected
    By L.LEE in forum Excel General
    Replies: 3
    Last Post: 07-01-2016, 01:32 AM
  6. Delete function not operating properly
    By ben646 in forum Excel General
    Replies: 0
    Last Post: 02-10-2012, 03:49 PM
  7. [SOLVED] Hyperlink Function not working as expected
    By Hari Prasadh in forum Excel General
    Replies: 2
    Last Post: 04-16-2005, 09:08 AM

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