+ Reply to Thread
Results 1 to 7 of 7

Delete row

  1. #1
    Registered User
    Join Date
    05-18-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Delete row

    I have this code that is intendent to don't remove rows containing "Arg1" and "Arg2", but all else rows. I almost got it to work, except from that I only can remove rows not containing one of the arguments but not both.

    This code is not working:
    Please Login or Register  to view this content.
    But if I modify this part, It will remove rows based on only one of the arguments, not both.

    Please Login or Register  to view this content.
    I would like it to considerate both the arguments, bot just only Arg1.

    Please help!

  2. #2
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Delete row - almost done!

    As far as I have seen excel doesn't have an "OR" ability like your trying to use. Try checking for one and then the other.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Delete row - almost done!

    Also:

    Please Login or Register  to view this content.
    is the same thing as

    Please Login or Register  to view this content.
    Or in otherwords using <> is the same as saying not equal to.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete row

    Excel absolutely has AND and OR functions in VBA, you just have to express each logic test completely.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Delete row

    Quote Originally Posted by JBeaucaire View Post
    Excel absolutely has AND and OR functions in VBA, you just have to express each logic test completely.
    Please Login or Register  to view this content.

    Really, because I don't see any words "OR" in that sentence. Having a function called "OR" and a function that does the same thing as an "OR" statement is two different things that accomplish the same thing.

    TL:DR You misunderstood what I was saying.

  6. #6
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Delete row

    111StepsAhead, if you click help in excel and type "or function" you will see that it does exist with examples of syntax but as you said not in the way Hello9000 was trying to use it
    Last edited by WasWodge; 05-22-2011 at 10:42 PM.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete row

    111StepsAhead, my example, which you quoted, was meant to correct the SYNTAX of a proper AND statement, wherein the logic test on each side of the AND must be a complete standalone test.

    Please Login or Register  to view this content.

    Now, an OR function operates exactly the same way.
    Please Login or Register  to view this content.
    The problem with using the OR function in this scenario is that this will ALWAYS be false, unless B = C. That's why I believe the AND function is appropriate for the OP's actual need.

    The error Hello9000 was making was that his second logic test was only half stated:
    Please Login or Register  to view this content.

    ...needed to be:
    Please Login or Register  to view this content.
    ...but if he makes this correction, the result is most likely TRUE every time because nonDelete1 and nonDelete2 would most likely not be the same value.


    EDIT: I also just noticed your negative rating to my post, makes no sense whatsoever. I not only understood what you were saying (Can you say, "Excel 101"?), I furthered your point by actually applying the idea you offered to an answer for the original poster, this forum isn't just about offering tidbits (which you did), but also offering a solution to the OPs question, which I did.

    I thought your post plus mine gave the OP what he needed, but your negative use of the rating system clearly shows a lack of clarity on your part what this thread is actually about. Unfortunate.
    Last edited by JBeaucaire; 05-22-2011 at 08:12 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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