+ Reply to Thread
Results 1 to 12 of 12

Comparing values in two columns and highlighting cells that don't match

  1. #1
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Comparing values in two columns and highlighting cells that don't match

    Good evening. Anyone who has ever had to manually compare two rows of data and pick out the values that don't match knows how much a pain in the butt it is. I'm hoping to automate the process and in doing so reduce the time it takes to compare values as well as decrease error rates in confirming that values match.

    I've attached a workbook that contains two columns of data, a workbook that I use to "analyze" my data that I export from the web based portal as a .CSV file and a screen shot of what the data looks like in the web based portal before I export it. The attached workbook has a complete list of department codes and their corresponding earnings codes.

    The first column in the workbook contains department codes which are made up of a 3 digit office location "prefix" and a 3 digit task "suffix". For example:

    502600 = (502) Waterville Office (600) Travel Time

    The second column contains earnings codes that are one or two word descriptors that correspond to the department codes. For example

    Travel Time
    Documentation
    Weekly Staffing

    To complicate things just a bit, some department codes are assigned only one earnings code while other department codes are assigned 5 or 6 earnings codes. For example:

    503600 = (503) Wilton Office (600) Travel Time
    503325 = (503) Wilton Office (325) Documentation
    503325 = (503) Wilton Office (325) Non-Billable
    503325 = (503) Wilton Office (325) Vacation


    Here's what I'm trying to accomplish with VBA code:

    1) I need the code to disregard (or delete) the first 3 digits in the earnings codes when comparing the last 3 digits with a corresponding department code.
    2) I need the code to confirm that the 3 digit earnings code matches with the department code that was chosen by the employee
    3) I need the cells that are mismatched to be highlighted


    I'm relatively new to VBA but I'm not looking for someone to write my code for me just to give me some pointers in a direction....I'm curious and determined enough to take bits and pieces that you might be able to offer and pull them together. Thanks for taking a look.

    Matthew
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by moosetales; 05-07-2014 at 11:14 AM.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Comparing values in two columns and highlighting cells that don't match

    I appreciate your details, but I am still confused...
    503600 = (503) Wilton Office (325) Travel Time
    Is that a mistake?
    1) I need the code to disregard (or delete) the first 3 digits in the earnings codes when comparing the last 3 digits with a corresponding department code.
    In your spreadsheet the earnings codes are text, so how do you remove the first three digits? I'll assume you meant Department codes, so then you remove the first three digits and compare it to what? Seems like you could (without VBA) create a column of just the last 3 digits and then sort the table.
    2) I need the code to confirm that the 3 digit earnings code matches with the department code that was chosen by the employee
    Again, earnings codes appear to be text in the spreadsheet. Also, how is the department code chosen by the employee? Is there a cell reference? A form?
    Sounds like you can filter a table to what the employee has chosen.
    3) I need the cells that are mismatched to be highlighted
    What is a mismatch. Is there an example in your spreadsheet?
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Comparing values in two columns and highlighting cells that don't match

    Pauley,

    [enter red face due to embarrassment] I've corrected my first post. Thanks for picking up on my error. Give me a bit and I will post a workbook that shows mismatched codes. Thanks.

  4. #4
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Comparing values in two columns and highlighting cells that don't match

    Okay, here's a demo of what I use to extract the data from the .CSV file that I save in a specific folder on my desktop. This allows me to sort the data as I need to as well as delete all the other columns (extra noise) that come along with the .CSV file. Let me know if this helps to clarify what I'm trying to do. Thanks.

    Matthew
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Comparing values in two columns and highlighting cells that don't match

    I guess I'm still at square one. I see some yellow cells, are they pertinent? I looked at your macros, and they seem to reading in the data, clearing some columns, and creating tables.
    In trying to glean what you are looking for, I added a column which has this formula
    =MOD([@[Worked Department]],1000)
    This essentially give the last three digits of 'Worked Department'. I then tried to see what the yellow cells were, so I sorted on 'Earnings Code'. I think the yellow represents your goal and that it is when there is only one instance of the three digit worked department tied to a specific earnings code. Example, there is only one 315 tied to Clinical Supervision, while there are multiple 315 tied to Client Cancellations. So, would that mean 370 tied to Client Cancellations should also be yellow, since it is unique, or am I missing something?

  6. #6
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Comparing values in two columns and highlighting cells that don't match

    Pauley,

    Thanks for hanging in there. I knew this would likely be a difficult question to convey on paper (screen).

    You are correct in that the last 3 digits of the Department Code is all I'm concerned with; the first 3 digits specify which office they work in and I don't care about that for this purpose. The yellow shaded cells represent a mismatch between the Department Code and the Earnings Code. Each Earnings Code may have only one or many Department Codes that it can be paired up with. For instance:

    The Earnings Code "Documentation" is permitted to be paired with any of the following Department Codes:
    50_315
    50_325
    50_370
    50_385
    50_387
    50_389

    whereas the Earnings Code "Travel Time" is permitted to be paired ONLY with the following Department Code:
    50_600

    What happens is my crew logs their time into ADP (web based portal) and assigns an Earnings Code and Department Code to each block of time they work. They are supposed to itemize their day, breaking it into the various tasks they completed (e.g. documentation, travel time, etc.) as well as the Department their time is supposed to be charged to (for accounting purposes).

    What happens is that sometimes they select the correct Earnings Code but inadvertently select the incorrect Department Code (or vise versa). For instance, out of a full day of work one of my crew may have spent 1 hour doing documentation. When they go into ADP they are supposed to log it as follows:

    Wed...5/7/14...1 hour....Documentation...50_315

    but sometimes they mess up and do as follows

    Wed...5/7/14...1 hour....Documentation...50_600

    Since 50_600 is not an approved Department Code for the Earnings Code of "Documentation" then this would be classified as a mismatched entry. I've attached an itemized list of all the Earnings Codes and their approved Department Codes in hopes of further clarifying my question.

    Thanks again for being curious enough to stick with this question.

    Matthew

  7. #7
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Comparing values in two columns and highlighting cells that don't match

    Pauley,

    I'm off to one of my kiddo's art shows at school so I may be out of pocket for a bit but I'll respond as soon as possible once I am home. Thanks.

    Matthew

    BTW...for anyone who is interested in this thread...if I can tame this beast of a project, I'll post the finished product and if you find it helpful, you are free to use it.
    Last edited by moosetales; 05-07-2014 at 09:30 PM.

  8. #8
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Comparing values in two columns and highlighting cells that don't match

    Okay, your last post with the spreadsheet clarified my third question.

    My first recommendation is to have this check done at the ADP. I would think it should have the ability to validate the person's input and have them correct it in real time rather than finding it later.

    Assuming that is not possible, then you need to create a table of valid values in your worksheet. The entries would be the concatenation of your three digit code and the text, so:
    461Clinical Supervision
    370Collateral Contacts
    325Contact Hours
    385Contact Hours
    ...

    You would then use conditional formatting with an equation something like this:
    =ISNA(MATCH(MOD($B2,1000)&$D2,Range_of_your_Validation_Table,0))
    and have this rule apply to $B$2:$E$405, assuming you want similar highlights in your example, but you can modify this range.

  9. #9
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Comparing values in two columns and highlighting cells that don't match

    Quote Originally Posted by Pauleyb View Post
    Okay, your last post with the spreadsheet clarified my third question.

    My first recommendation is to have this check done at the ADP. I would think it should have the ability to validate the person's input and have them correct it in real time rather than finding it later.
    I whole heartedly agree with your statement above. I have tried and tried to find a way within my system as well as have asked if the ADP company can program this for us but I am told that it does not exist

    I will take a look at your suggestions in a little bit and let you know the results. Thanks again for chiming in.

    Matthew

  10. #10
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Comparing values in two columns and highlighting cells that don't match

    Pauley,

    I'm making headway on the workbook. At first glance, the code appears to be working I just have to figure out how to integrate it into my workbook so it compliments and doesn't compete the existing code. I would not have guessed that one formula could do all that this. It's so cool. Thanks and I'll be in touch.

    Matthew

  11. #11
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Comparing values in two columns and highlighting cells that don't match

    Pauley,

    Good morning. So far I've had moderate fortune in getting the form to respond as I hoped. The formula you provided worked a charm. I've got a few more glitches to work out but the problem at the core of this thread is SOLVED. Thanks.

    If parting, if the last row in my .csv files varied from file to file, how would I represent that in the formula you provided so the shading did not extend all the way to row 405? Thanks.

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

  12. #12
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Comparing values in two columns and highlighting cells that don't match

    Pauley,

    Good morning. So far I've had moderate fortune in getting the form to respond as I hoped. The formula you provided worked a charm. I've got a few more glitches to work out but the problem at the core of this thread is SOLVED. Thanks.

    If parting, if the last row in my .csv files varied from file to file, how would I represent that in the formula you provided so the shading did not extend all the way to row 405? Thanks.

    Please Login or Register  to view this content.
    Also, is there a way to build the following formula into VBA code so I don't need to re-enter it each time my workbook is opened? Thanks.

    Please Login or Register  to view this content.
    Thanks again.

    Matthew

+ 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. Comparing two columns and highlighting values
    By Zaid in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-15-2013, 03:12 AM
  2. Comparing columns and highlighting differences
    By Sejrup in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-01-2010, 09:24 AM
  3. Replies: 2
    Last Post: 08-12-2010, 05:54 AM
  4. Comparing 2 columns, highlighting the higher number
    By Hagi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-01-2009, 01:17 PM
  5. Comparing values and Highlighting
    By Alfarata in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2008, 10:22 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