+ Reply to Thread
Results 1 to 11 of 11

VBA/Macro - Delete rows if 2 conditions are met

  1. #1
    Registered User
    Join Date
    09-19-2018
    Location
    Australia
    MS-Off Ver
    MS Office 365
    Posts
    9

    VBA/Macro - Delete rows if 2 conditions are met

    Location Sub Locn Catalogue Order Number Supplier Name Order Date Requisition Created By Line No. Item Description Supplier Product Nbr UOM Qty Ordered Unit Price Total Price Delivery Point Account No.
    BAS AST CAT ACH109 EDI SUPPLIER 02/08/2018 NICK 00003 Widget ABC ONLY 10 138.23 1382.3 ACH 1920120730114
    BASS AST CAT ACH110 EDI SUPPLIER 22/08/2018 NICK 00004 Widget DEF ONLY 10 7.35 73.5 ACH 1940120130114
    BAS AST CAT ACH110 EDI SUPPLIER 02/08/2018 NICK 00001 Widget GHI ONLY 6 45.58 273.48 ACH 1920120730125

    Note:
    1. I want to delete rows in which the Column Q number doesn't end with 30114
    2. Then I want to delete the rows in which Column A has more than 3 letters
    3. Need Macro to tackle both the problems


    Thanks

    Nikhil

  2. #2
    Registered User
    Join Date
    09-14-2018
    Location
    Sydney
    MS-Off Ver
    2013
    Posts
    4

    Re: VBA/Macro - Delete rows if 2 conditions are met

    Hi !

    See my reply to cad1610

    The conditions can be modified inside the loop to suit most/many/more than 1 requirement ( Universal - worked once - might work again )

  3. #3
    Registered User
    Join Date
    09-19-2018
    Location
    Australia
    MS-Off Ver
    MS Office 365
    Posts
    9

    Re: VBA/Macro - Delete rows if 2 conditions are met

    How can I modify the two different conditions - one is last 5 digits need to be same and the other condition was that the letters in a cell should be less than equal to 3?

    Thanks

  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    Re: VBA/Macro - Delete rows if 2 conditions are met

    May be like this. Please try on a copy first.

    Please Login or Register  to view this content.
    Teach me Excel VBA

  5. #5
    Registered User
    Join Date
    09-19-2018
    Location
    Australia
    MS-Off Ver
    MS Office 365
    Posts
    9

    Re: VBA/Macro - Delete rows if 2 conditions are met

    If Right$(.Range("O" & i).Value, 5) <> 30114 And Len(.Range("A" & i).Value) > 3 Then

    I get error message -

    Run-time error '13:
    Type mismatch

  6. #6
    Registered User
    Join Date
    09-19-2018
    Location
    Australia
    MS-Off Ver
    MS Office 365
    Posts
    9

    Re: VBA/Macro - Delete rows if 2 conditions are met

    If Right$(.Range("O" & i).Value, 5) <> 30114 And Len(.Range("A" & i).Value) > 3 Then

    I get error message -

    Run-time error '13:
    Type mismatch

  7. #7
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    Re: VBA/Macro - Delete rows if 2 conditions are met

    Now?

    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    Re: VBA/Macro - Delete rows if 2 conditions are met

    Attach a sample of your workbook if it is still not working

  9. #9
    Registered User
    Join Date
    09-19-2018
    Location
    Australia
    MS-Off Ver
    MS Office 365
    Posts
    9

    Re: VBA/Macro - Delete rows if 2 conditions are met

    Nope Doesn't work - Please see attached file for reference.

    ThanksAttachment 590786

  10. #10
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    Re: VBA/Macro - Delete rows if 2 conditions are met

    Unable to download your attachment.

  11. #11
    Registered User
    Join Date
    09-19-2018
    Location
    Australia
    MS-Off Ver
    MS Office 365
    Posts
    9

    Re: VBA/Macro - Delete rows if 2 conditions are met

    Sorry the macro is not working? What could be the reason?

+ 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] Help combining macros to delete rows on conditions and add data into cells on conditions
    By JayJayGC in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-03-2017, 10:14 AM
  2. [SOLVED] Need a macro to delete rows based on multiple conditions
    By WorkAccount2 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-30-2017, 12:33 PM
  3. [SOLVED] Delete rows with conditions
    By yukioh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2016, 10:42 PM
  4. [SOLVED] Macro to Delete Rows based on Specific Conditions
    By stockgoblin42 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-28-2013, 05:29 PM
  5. Macro to delete rows with conditions
    By adray13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2012, 11:05 AM
  6. [SOLVED] Macro required to delete rows with multiple conditions
    By bigband1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2012, 03:53 AM
  7. Macro program to autofilter and delete specific rows with conditions
    By MAKRUMAHESH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2012, 09:05 PM

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