+ Reply to Thread
Results 1 to 18 of 18

Macro Help need to delete rows with certain criteria

  1. #1
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

    Arrow Macro Help need to delete rows with certain criteria

    How would i go about writing a vba code line that loops through a range and deletes rows where the cell value does not equal the value of the cell above or below?

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    What is the range through which you want to loop?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

    Re: Macro Help need to delete rows with certain criteria

    A11 through Until A cell is blank

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    Is there data in A10 and do you want to delete row 11 if it meets your criteria? What would you like to do with the last used row in column A? Since the cell below the last used cell in column A will always be blank, the row in that last used cell will always be deleted.

  5. #5
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

    Re: Macro Help need to delete rows with certain criteria

    I want it so as long as it matches at least one of the cells above or below. so as long as A11 has a match below it will not delete and as long as the last cell matches the cell above it will not delete.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    Try:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

    Re: Macro Help need to delete rows with certain criteria

    this is perfect! thank you, now what if i want to also have it remove duplicate "MDU Self monitored" charges From E11 until there is no value in the cell but remove the cell with the lesser value shown in cell I?

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    I'm sorry but I don't follow. Could you attach a copy of your file and explain what you want to do in detail referring to specific cells, rows and columns using a few examples from your data?

  9. #9
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

    Re: Macro Help need to delete rows with certain criteria

    Nevermind, How would i do a macro that starts at A11 that deletes duplicates where if Row A of the Column and row E match with any other rows. Sorry i cannot provide samples as it is a specific bill that cannot be disclosed.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    Perhaps a de-sensitized file?

  11. #11
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

    Re: Macro Help need to delete rows with certain criteria

    DeSensitized.PNG

    Not sure if this attached. I don't want any of the equipment fees to be deleted. Just the duplicate MDU Self monitored for the specific address
    Attached Images Attached Images

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    I'm sorry for being a "pain" but it's hard to work with a picture. Could you please attach the file? Looking at the second image, you would want to remove rows 19, 28, 31 and 34. Is that correct? What do you mean by "I don't want any of the equipment fees to be deleted."? In which column are the equipment fees? It would help if you could include a second sheet that shows the desired result in the copy of the file you post.

  13. #13
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

    Unhappy Re: Macro Help need to delete rows with certain criteria

    the highlighted fields are the ones i want the code to use as reference as you can see there are 2 rows that say "Apartment 9" and "MDU Self Monitored Security" I need it to remove the first one of these if there are duplicates (See Outcome tab). In Row E there will potentially be duplicate equipment charges, but i do not want it to delete these duplicates. I only want the duplicate MDU Self Monitored Security charges to be deleted.

  14. #14
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

    Re: Macro Help need to delete rows with certain criteria

    the attachment button does not function

  15. #15
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    To add an attachment, click the "Go Advanced" button. Then scroll down a bit and click "Manage Attachments".

  16. #16
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    Mis-posted. Sorry.
    Last edited by Mumps1; 07-02-2019 at 05:10 PM.

  17. #17
    Registered User
    Join Date
    05-14-2019
    Location
    Provo, Utah
    MS-Off Ver
    2013
    Posts
    26

  18. #18
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro Help need to delete rows with certain criteria

    I need some clarification. Comparing the 2 files, the first row you want to remove is row 18 which has "Apartment 8" in column A and "MDU Self Monitored Security" in column E. However, in the Outcome file, "Apartment 8" still appears in column A. The same is true for the other rows containing "MDU Self Monitored Security ". In the De-sensitized file, Rows 39 to 43 contain "220 Riverside Ave Unit 651" in column A. I can understand why row 42 (duplicate row) would be deleted but why are rows 39 to 41 and row 43 also deleted? Those rows don't appear in the Outcome file.

+ 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. Macro to delete certain rows if DATE criteria is met
    By lukasz_rz in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-28-2014, 11:30 AM
  2. Macro to delete certain rows if DATE criteria is met
    By lukasz_rz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2014, 01:16 PM
  3. Macro to delete rows not containing multiple criteria
    By jerrydiaz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2013, 09:06 AM
  4. [SOLVED] Help on writing a Macro to delete rows with certain criteria
    By cf7046 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2012, 06:45 PM
  5. [SOLVED] Macro or Function to delete rows if both criteria are not met
    By nrsChristine in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-12-2012, 07:11 PM
  6. Macro to delete rows meeting criteria
    By D_N_L in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2012, 05:21 AM
  7. Macro, delete rows that meet criteria
    By Scott Wagner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-22-2005, 08:10 PM

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