+ Reply to Thread
Results 1 to 14 of 14

macro to create forward balances by deleting rows (and cells) and changing invoice numbers

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

    macro to create forward balances by deleting rows (and cells) and changing invoice numbers

    Hey all,

    Please see attached spreadsheet for examples.
    In this workbook, I have purposely made all the payments (Column I) not quite offset the sales amounts (Column H)
    I need a macro that will look at the subtotaled due bill amount, and apply a forward balance to the customer.
    Since I’m not quite sure how to put this into words, I’ll describe exactly what I’m hoping the macro will do to the example spreadsheet:

    • Row 7 is -$0.01, so delete rows 2 through 5, change cell H6 to 0 and change cell I6 to 0.01. Add an “FB” at the end of inv# 10550 in cell G6 (FB for Forward Balance)
    • Row 11 is $20.00. Since it’s less than the last invoice for that customer, apply a forward balance to it by: Deleting rows 8 and 9, change cell I10 to zero, change cell H 10 to $20.00 and add an FB to the end of inv# 25779 in cell G10.
    • Row 14 is -$10.00. Delete row 12, change cell H13 to zero and change cell I13 to $10.00. Add an “FB” to the end of inv# 98779 in cell G13
    • Row 24 is -$1.36, so delete rows 15 through 22. Change cell H23 to zero and change cell I23 to $1.36. Add an “FB” at the end of invoice # 11120 in cell G23
    • Row 28 is $2.00, so delete rows 25 and 26, change cell I27 to zero and change cell H27 to $2.00. Add an “FB” to the end of inv# 10103 in cell G27.

    Please let me know if any additional clarification is required.

    forward balances.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 create forward balances by deleting rows (and cells) and changing invoice num

    Hi BWaite,

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 04-15-2013 at 09:07 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 create forward balances by deleting rows (and cells) and changing invoice num

    I can't even describe how much easier you've made my life lol
    Thanks so much Xladept, I'll give it a spin at work tomorrow

  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 create forward balances by deleting rows (and cells) and changing invoice num

    You're welcome! Let me know of any issues

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

    Re: macro to create forward balances by deleting rows (and cells) and changing invoice num

    Hey Xladept,

    I gave it a go today, but with no luck.

    it gave me the following error:

    Run-time error '13':
    Type mismatch

    And when I debugged it highlighted the following line of code:
    Please Login or Register  to view this content.
    I'm not sure what's wrong, because it worked fine with the sample spreadsheet.
    I'm using a large spreadsheet now where i use the previous macro you made for me, and then run this one afterwards. Maybe it doesn't like having invoices that actually offset?

    Can you help?

  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 create forward balances by deleting rows (and cells) and changing invoice num

    Hi BWaite,

    When you ran the first routine it may have deleted the Current Receipt needed for the second - can you post a sample that fails??

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

    Re: macro to create forward balances by deleting rows (and cells) and changing invoice num

    I'll post one bright and early tomorrow. I don't have one at home unfortunately

  8. #8
    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 create forward balances by deleting rows (and cells) and changing invoice num

    OK then tomorrow - which routine did you run before the FB - the first one?

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

    Re: macro to create forward balances by deleting rows (and cells) and changing invoice num

    Ok…so it turns out I’m dumb and forgot to change r to r=7 (had it set to r=1)
    So this time it ran and it worked..sort of.
    The problem is it turned everything into a forward balance, and something else went wrong because the grand total changed.
    If it’s possible, I’d like it to only create a FB under the following condition:

    • If the Cust # Subtotal in column J is less than the Sales amount of the invoice just above it in column H (the most current one)

    The way you had it make the FB was perfect, a positive FB should be in the Sales amount column, and a negative FB should be in the payments column.
    Thanks again!

    Assume I've run the below routine before going to use the FB:

    Please Login or Register  to view this content.

  10. #10
    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 create forward balances by deleting rows (and cells) and changing invoice num

    Hi BWaite,

    You've posted the code - will a sample be forthcoming?

    Without the sample - the best I can do is try to code your condition:

    Please Login or Register  to view this content.
    Last edited by xladept; 04-17-2013 at 02:24 PM.

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

    Re: macro to create forward balances by deleting rows (and cells) and changing invoice num

    sorry, forgot to attach the file, here you go:

    due bill macro2.xlsx

  12. #12
    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 create forward balances by deleting rows (and cells) and changing invoice num

    Hi BWaite,

    Try this with "the condition" commented out first:

    Please Login or Register  to view this content.

    BTW - How should we handle 0 forward balances?

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

    Re: macro to create forward balances by deleting rows (and cells) and changing invoice num

    I gave it a try but it turns all invoices into FBs.
    If the total for the customer is less than the final invoice, than it should create a FB, if not then it should do nothing.

    does that answer your question about 0 forward balances?

  14. #14
    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 create forward balances by deleting rows (and cells) and changing invoice num

    OK - then uncomment the condition and see if that's what you want.

    BTW - The total formula at the end should include one more row.

    Please Login or Register  to view this content.

+ 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