+ Reply to Thread
Results 1 to 8 of 8

Macro to Delete Rows based on Specific Conditions

  1. #1
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Macro to Delete Rows based on Specific Conditions

    Hi,

    I have a page of paralell lines. The slopes are listed in column A. I need to make a macro that keeps only the lines that match the first 3 slopes.

    Please see the attached worksheet.

    So, in the worksheet attached, the only lines that would be left after running the macro would be the ones with slopes of -0.04, -0.03 and -0.18. I've highlighted them for clarity.

    What's the best approach to this. Is it even possible?
    Attached Files Attached Files
    Last edited by stockgoblin42; 05-26-2013 at 06:57 AM.
    live logic & long prosper

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro to Delete Rows based on Specific Conditions

    Try this :

    Please Login or Register  to view this content.
    Please click the * below if this helps

  3. #3
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Re: Macro to Delete Rows based on Specific Conditions

    oH, oH, i found a special case. If the first 3 slopes match then this macro doesn't do exactly what I need

    to be more precise:
    I need to make a macro that keeps only the lines that match the first 3 "UNIQUE" slopes.

    can a simple change be made to accomodate this?

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro to Delete Rows based on Specific Conditions

    Try this :

    Please Login or Register  to view this content.
    Please click the * below if this helps
    Last edited by JasperD; 05-26-2013 at 11:34 AM. Reason: slimmed the code a bit

  5. #5
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Re: Macro to Delete Rows based on Specific Conditions

    Excellent thanks. Just doesn't like it if there are less than 3 unique slopes.
    Last edited by stockgoblin42; 05-26-2013 at 09:28 PM.

  6. #6
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro to Delete Rows based on Specific Conditions

    I didn't think you'd have less than 3 unique slopes.

    Try amended code below :

    Please Login or Register  to view this content.
    Please click the * below if this helps

  7. #7
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Re: Macro to Delete Rows based on Specific Conditions

    Nice. Wow, you can do almost anything with programming, hey?

    I'm having problems with some data having way too many parallel matches though.

    I'm interested in seeing the first 3 unique slopes and instead of all their matches, just the first one? So only 6 lines would be left.

    Is that easy to do?

  8. #8
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro to Delete Rows based on Specific Conditions

    Since you specifically mention three slopes, I adjusted the code I gave you in the first place. If you want it to work for 1 or 2 slopes, just adjust the other code yourself (is good exercise for you )

    Please Login or Register  to view this content.
    Again, if this helps you, please click the * below

+ 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