+ Reply to Thread
Results 1 to 21 of 21

Delete rows based on multiple criteria (Date & Text)

  1. #1
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Delete rows based on multiple criteria (Date & Text)

    Please Register to Remove these Ads

    Hello,

    I'm quite a novice here. I'm trying to delete rows where column C contains specific text in some instances. In other cases I am trying to delete rows where specific text is found in column C AND column M contains the year 2009 (in format dd-mm-yyyy).

    The code I'm working with so far is as follows:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Poulan; 10-08-2010 at 09:12 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Delete rows based on multiple criteria (Date & Text)

    i have slightly modified your macro (see third row from below).see whether it helps
    the default property of a range is its value
    you can write
    Please Login or Register  to view this content.
    but it is enough if you write
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Delete rows based on multiple criteria (Date & Text)

    This is what I've got now but I'm getting a run time error 424 and the actual macros is failing to do anything:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Delete rows based on multiple criteria (Date & Text)

    You have not defined (the worksheet?) EntryDate.

    This code might be better
    Please Login or Register  to view this content.
    I suspect that EntryDate is not required, but can't be sure.


    Hope this helps
    Last edited by Marcol; 10-08-2010 at 04:51 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Delete rows based on multiple criteria (Date & Text)

    Ok, I've removed the EntryDate but now I'm getting a compile error on line 12 with
    Please Login or Register  to view this content.
    highlighted by the debugger.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Delete rows based on multiple criteria (Date & Text)

    Sorry, my mistake I didn't define LastRow

    Try this
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Delete rows based on multiple criteria (Date & Text)

    Thanks for looking at this buddy. It ran without errors and successfully deleted the "Germany Domestic" rows but didn't touch the "Intl Corporate" ones which have 2009 in column M. The logic of the macro should mean that it deletes 3 of the 5 "Intl Corporate" entries. I'm not sure why this is not working. I've uploaded the sheet again to help anyone who wants to test it with the macro as I have it with the changes. On "Sheet2" is the original data for pasting back into "Sheet1" for retesting.
    Attached Files Attached Files

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Delete rows based on multiple criteria (Date & Text)

    Or
    Please Login or Register  to view this content.
    NB. this code runs only if 'option explicit' has been removed or 'hyphenated'



  9. #9
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Delete rows based on multiple criteria (Date & Text)

    That code ran but didn't delete any of the "Intl Corporate" records from "2009".

  10. #10
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Delete rows based on multiple criteria (Date & Text)

    Try this
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Delete rows based on multiple criteria (Date & Text)

    Great, I'm going to try to understand why it didn't work out in the first place. In the mean time: I love you

  12. #12
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Delete rows based on multiple criteria (Date & Text)

    Glad to have helped

    Column M contains a Date
    Therefore you need
    Please Login or Register  to view this content.
    to return e.g. 2009

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Delete rows based on multiple criteria (Date & Text)

    In that case:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Delete rows based on multiple criteria (Date & Text)

    Quote Originally Posted by snb View Post
    In that case:

    Please Login or Register  to view this content.
    I tried that but it gave a "run time error 13, type mismatch" error

  15. #15
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Delete rows based on multiple criteria (Date & Text)

    Quote Originally Posted by Marcol View Post
    Glad to have helped

    Column M contains a Date
    Therefore you need
    Please Login or Register  to view this content.
    to return e.g. 2009
    I've imported your code and used that logic to form part of a slightly larger macro (I wanted to keep it simple for uploading here so that I could get the logic) but it's failing.

    The error I am getting is "Compile error, Case without Select Case" on this line: "Case "DINERS ONLY NEW MERCHANTS""

    I've looked over it thoroughly so it must be something very small.

    Please Login or Register  to view this content.

  16. #16
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Delete rows based on multiple criteria (Date & Text)

    It's evident that the first row shouldn't be included.

    Please Login or Register  to view this content.
    Last edited by snb; 10-08-2010 at 08:35 AM.

  17. #17
    Registered User
    Join Date
    10-08-2010
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    9

    sorting the row and get all row which contains the same data many times

    Hi

    I have an exel likes this

    NAME LOC DETAILS
    A XX 1000,SWATHY
    B XX 2000,NANDHU
    C XX 1000,BEENA
    D YY 1000,ANU
    E XX 2000,MAYU
    F YY 3000,RAMYA
    F XX 4000,JINU

    I need to sort DETAILS row and get all row which contains the same data many times.like:

    NAME LOC DETAILS
    A XX 1000,SWATHY
    C XX 1000,BEENA
    D YY 1000,ANU
    B XX 2000,NANDHU
    E XX 2000,MAYU

    can any one help me please....


    swathi

  18. #18
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: sorting the row and get all row which contains the same data many times

    You need to start a new message thread because this is unrelated to the current discussion.

  19. #19
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Delete rows based on multiple criteria (Date & Text)

    Try this to see if it is what you are after.
    Please Login or Register  to view this content.

    Is this correct? If not post a sample workbook with more typical data, your last sample doesn't cover your criteria

  20. #20
    Registered User
    Join Date
    10-05-2010
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: Delete rows based on multiple criteria (Date & Text)

    You are an awesome person. I hope that my words make you sit back and feel great for at least the length of time that you spent looking through this for me.

  21. #21
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Delete rows based on multiple criteria (Date & Text)

    That is perhaps not the best code for your purpose, but I feel that it will help you see how to step through your process, and then, when you understand how it works, you can improve it yourself.

    Happy to have helped

    Please mark your thread [Solved] if you are happy that your question has been answered.

+ 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