+ Reply to Thread
Results 1 to 6 of 6

macro to delete rows where payments offset sales

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    Kitchener, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    39

    macro to delete rows where payments offset sales

    Hey all,
    I need some help making a macro.
    Please see the attached sample workbook.
    Column G is sales, and H is payments received.
    I would like to have a macro that will delete all rows where the payment offsets the invoices above it. So you can see what I mean, I’ve highlighted all cells that offset each other in blue. So once I run the macro I would like all those rows to be gone.
    Can anyone help me out with this?

    my normal range is usually around A1:I3000

    Book1.xlsm

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: macro to delete rows where payments offset sales

    Hi BWaite,

    Try this:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    Copy the code to the clipboard

    Open your Workbook

    Save your Workbook or Another Workbook designated for Macros as Macro_Enabled

    Press ALT + F11 to open the Visual Basic Editor.

    Select “Module” from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    Last edited by xladept; 04-11-2013 at 09:26 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    12-13-2012
    Location
    Kitchener, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: macro to delete rows where payments offset sales

    wow it worked, thanks!
    One more question, how would I make this work if my data started in row 7 (headers are in row 7).
    Blank space is above. Sorry, it's important, should have made it that way in my sample

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: macro to delete rows where payments offset sales

    Hi BWaite,

    I changed the program a little - to answer your question:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-13-2012
    Location
    Kitchener, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: macro to delete rows where payments offset sales

    Ah, so that's what r means.
    Thanks so much XLAdept

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: macro to delete rows where payments offset sales

    You're welcome! Don't forget to incorporate the updated line
    Please Login or Register  to view this content.
    in your copy!

+ 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