+ Reply to Thread
Results 1 to 9 of 9

How to write a macros to compare to columns & match amounts, but this is a bit more tricky

  1. #1
    Registered User
    Join Date
    05-14-2015
    Location
    Chicago, Illinios
    MS-Off Ver
    2007
    Posts
    35

    How to write a macros to compare to columns & match amounts, but this is a bit more tricky

    Ok guys so i pull in a report. On the left side its the rebates that AP have applied. On the right side its what AR applied.

    Column D is totaled and its sum should match to the sum of column S. If they don't something is off and i have to manually search which amounts are off.

    So in sheet 2 i paste Column D for AP side rebates into column A.

    Column C and so on, is column S, T, Z and AF.

    Columns T Z and AF are basically totaled together to get what you get in the S column. So the way i manually do this in sheet 2 is if Column C does have a combination of totals, i delete whats in column C, and Put whats in columns D, E and F, into rows in Column C. Example


    Column C D E F
    18,869.23 909.23 803.00 17157.00

    turns into:

    C
    909.23
    803.00
    17157.00

    So this pushes the numbers beneath it down accordingly. If column C & D are equal i just delete whats in the D cells. All this is seen in sheet 3. Then in sheet 4, i sort them my least to greatest and find whats not adding up.

    Is there a way to write a macros to do this for me?
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to write a macros to compare to columns & match amounts, but this is a bit more tr

    I am a bit confused. I noticed that Column D is the total of the next three columns under all situations. Will this always be true? If so then why are you checking to see if C = D or is it if C=D then you ignore what comes after on the same row, even if there is data there?

    P.S. I also noticed that Column D on the original sheet has some positive and negative balances that cancel each other out (mostly they are consecutive, but not necessarily).

    Is there any other "binding" such as an account or invoice number or are you going strictly on amounts which might be coincidentally equal for unrelated APs and ARs?
    Last edited by dflak; 09-26-2016 at 10:24 AM. Reason: Add PS
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    05-14-2015
    Location
    Chicago, Illinios
    MS-Off Ver
    2007
    Posts
    35

    Re: How to write a macros to compare to columns & match amounts, but this is a bit more tr

    Quote Originally Posted by dflak View Post
    I am a bit confused. I noticed that Column D is the total of the next three columns under all situations. Will this always be true? If so then why are you checking to see if C = D or is it if C=D then you ignore what comes after on the same row, even if there is data there?

    P.S. I also noticed that Column D on the original sheet has some positive and negative balances that cancel each other out (mostly they are consecutive, but not necessarily).

    Is there any other "binding" such as an account or invoice number or are you going strictly on amounts which might be coincidentally equal for unrelated APs and ARs?
    Column C basically equals the summation of column D, E, and F.

    so if columns E and F are blank C will always equal D.

    The ones that are positive and negative of equal amounts wash each other out and i just delete those. And, im going strictly on amounts. Basically the amounts on both sides of AP and AR have to be the same, if they're not, that means that AP or AR didnt apply a rebate payment.

  4. #4
    Registered User
    Join Date
    05-14-2015
    Location
    Chicago, Illinios
    MS-Off Ver
    2007
    Posts
    35

    Re: How to write a macros to compare to columns & match amounts, but this is a bit more tr

    So i guess the easiest thing would be just to remove column C completely, and just have columns D E and F transpose down into a row all the way through, and then sorting it least to greatest would get rid of the blank cells, right?

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to write a macros to compare to columns & match amounts, but this is a bit more tr

    The objective here is to look for all APs that do not have a matching AR regardless of column. Is that correct?

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to write a macros to compare to columns & match amounts, but this is a bit more tr

    Here is what I did.

    First I converted the two groups of data on the Data Sheet to Excel Tables. Excel Tables have many benefits as described here: http://www.utteraccess.com/wiki/inde...ables_in_Excel.

    Those that are most important to this solution are:
    - Tables “know” how big they are so you don’t have to change formulas when you change the number of rows in a table. I look up against Table_AR (the green table) and I don’t want to change the lookup range when the size of the AR range changes.
    - Tables “remember” and copy down formulas. So you can clear out the old data (see the link on how to do this) and copy and paste in the new data and the formulas will be there.
    - The total row doesn’t care where it winds up. It “knows” how many rows are above it and sums them accordingly.

    I added some helper columns in Columns J:M. Column J looks for the value in Col X. Column K looks for the value in Col AD and Column L looks for the value in Col AJ.

    Column M is true if the value is found in any of these columns.

    I then applied some conditional formatting to the table (yes, it grows and shrinks with the table too) to shade the cells a light orange if the value is not found in any of the three columns.

    There are some false alarms such as in rows 21 and 22 where 3,896.00 is offset by (3,896.00). I leave it as an exercise for the reader (I just loved when my math books said that ) to use another helper column to check for positive / negative pairings even if they are not contiguous (Hint: use ABS, ISNUMBER and MATCH) on Column D and use conditional formatting to shade them some other color.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-14-2015
    Location
    Chicago, Illinios
    MS-Off Ver
    2007
    Posts
    35

    Re: How to write a macros to compare to columns & match amounts, but this is a bit more tr

    Quote Originally Posted by dflak View Post
    I am a bit confused. I noticed that Column D is the total of the next three columns under all situations. Will this always be true? If so then why are you checking to see if C = D or is it if C=D then you ignore what comes after on the same row, even if there is data there?

    P.S. I also noticed that Column D on the original sheet has some positive and negative balances that cancel each other out (mostly they are consecutive, but not necessarily).

    Is there any other "binding" such as an account or invoice number or are you going strictly on amounts which might be coincidentally equal for unrelated APs and ARs?
    Quote Originally Posted by dflak View Post
    The objective here is to look for all APs that do not have a matching AR regardless of column. Is that correct?

    This is ******* awesome. So i can save this as a template and just copy and paste a new report that i pull in from access onto this and the formulas remain in tact?

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to write a macros to compare to columns & match amounts, but this is a bit more tr

    Yes you can use it as a template. Make sure that you have filters either turned off or selecting everything. Then highlight the rows between the header row and total row (but not including these rows) and right click and select Delete from the dropdown menu. You should see Table Rows as an option. If you see Entire Row, then you have some hidden rows.

    When you delete the rows, you should be left with the header row and the total row with a blank row in between. Paste your new data there.

  9. #9
    Registered User
    Join Date
    05-14-2015
    Location
    Chicago, Illinios
    MS-Off Ver
    2007
    Posts
    35

    Re: How to write a macros to compare to columns & match amounts, but this is a bit more tr

    Thanks man you're awesome!

+ 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. Replies: 6
    Last Post: 09-21-2016, 04:21 PM
  2. [SOLVED] Compare two columns and write which is existing in B in C Column
    By uday1969 in forum Excel General
    Replies: 5
    Last Post: 02-04-2015, 12:59 AM
  3. Macro to Compare two columns and publish sheet name in case columns dont match
    By adaws in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-06-2014, 01:21 PM
  4. Replies: 2
    Last Post: 02-23-2014, 09:56 PM
  5. [SOLVED] Compare colunns and if do not match write row to a new sheet
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2013, 05:48 PM
  6. [SOLVED] HOW DO MATCH AND ELIMINATE AMOUNTS IN TWO COLUMNS IN EXCEL
    By SNOWBREEZE3 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-13-2005, 05:05 PM
  7. How do I write a VBA code in excel that will compare two columns .
    By PenelopeinCinci in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-14-2005, 01:06 PM

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