+ Reply to Thread
Results 1 to 2 of 2

Macro to delete rows if sum of rows is greater than a given value

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    Seattle, WA
    MS-Off Ver
    Office 365
    Posts
    67

    Unhappy Macro to delete rows if sum of rows is greater than a given value

    I have a macro that adds the value in column A if values in column B are the same, and these sums are reported in column D.
    If the sum is greater than 100, I want to delete the rows that comprised the sum. I'm not sure how to track the rows that go to each sum in VBA. Please Help1
    Spreadsheet attached.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,945

    Re: Macro to delete rows if sum of rows is greater than a given value

    You could just make a pivot table from that - with Length as the row field, and Width Org as the data field, I get


    Row Labels Sum of WIDTH ORD
    5,526 99.75
    5,535 113
    5,546 220
    5,548 108.75
    5,558 117.1875
    5,560 99.75
    5,564 326.9375
    5,565 227.75
    5,568 326.9375
    5,585 91.3125
    5,589 217.5
    5,882 117.1875
    5,945 117.1875
    5,949 117.1875
    6,027 117.1875
    6,051 117.1875
    6,060 117.1875
    6,080 117.1875
    6,162 117.1875
    6,300 113.6875
    6,390 113.6875
    6,450 108.5
    Grand Total 3222.25

    In any event, your macro should not be using Integers - use Double for the sum and Long for the indexing.

    If you need to have some of your values reported in two blocks, then use the subtotal utility, which can sum column A based on changes in column B. The underlying data can be hidden as an option, like so:

    Capture.JPG
    Last edited by Bernie Deitrick; 04-06-2017 at 04:34 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

+ 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] macro to delete rows if greater than or less than
    By burdo77 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-19-2014, 01:11 AM
  2. [SOLVED] Delete all rows with a date greater than ...
    By Moriexcel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-14-2014, 09:30 AM
  3. copy and delete rows that have values greater than defined cells
    By josh-mediwatch in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-31-2014, 09:29 AM
  4. [SOLVED] Delete Rows greater than current date
    By kesavanprabhu in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-13-2013, 10:57 AM
  5. [SOLVED] Delete rows with Start date greater than 30 days
    By kbaruin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-27-2012, 04:56 AM
  6. Delete Rows Column F if greater than or equal to zero.
    By EJensen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2009, 10:06 PM
  7. Delete Rows with Value greater than X
    By STEVEB in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2005, 04:08 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