+ Reply to Thread
Results 1 to 5 of 5

Macro to compare 2 columns cell contents and add 'Yes' flag for record

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Rochester, NY
    MS-Off Ver
    Excel 2007
    Posts
    3

    Macro to compare 2 columns cell contents and add 'Yes' flag for record

    Hi All - I have used this forum many times but this is the first time I am posted a question. I am looking for a solution that will help flag records in a spreadsheet that meet criteria. I have a very large spreadsheet of data from an HRIS system. It has over 50,000 rows. I have done a visual check, but hope to find a programatic way to ensure I caught everything. I do not have access to the HRIS system, I have to work with the export.
    We discovered that some teams in the company have different codes assigned to them. We need to flag all records where the collective team name is the same but the team code changes.

    In the example this file is sorted on Column C and a secondary sort on column D. This groups the team names together for visual checking.
    Column C contains the 'TeamName' and Column D contains the 'TeamCode'. I need to flag records where the same name is entered in Column D in above and below cells, but the TeamCode assigned to that name has changed if compared to above or below cells. I need to flag all records that meet this criteria so we can update them correctly in the system.
    If you look at 'Problem Management', it has multiple team codes assigned to it. In this case, I have flagged all records containing 'Problem Management' with 'Yes' in the last column. 'Mailing Services' has same code assigned to it so we do not need to flag this.

    I attached a spreadsheet with sample information. Please let me know if I have left critical information out or if there is a solution using a different tool.

    I have attempted to solve by isolating the columns and selecting remove duplicates. Then attempted a v-lookup. This did not provide the correct outcome. I have also tried creating a pivot table and looking for cases where a TeamName has more than 1 TeamCode. I could not figure out how to get it to filter on that criteria. I think an VBA macro is needed but I am not experienced writing code.

    Thank you!

    Example described above.

    picture-forum.jpg
    forum example.xlsx
    Last edited by swarren6; 02-08-2013 at 07:32 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to compare 2 columns cell contents and add 'Yes' flag for record

    Try this code -
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

    If you want the sort action to be included in the code, it can be done as well.
    Also, should TeamCode-Blank be highlighted as well?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    12-06-2012
    Location
    Rochester, NY
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro to compare 2 columns cell contents and add 'Yes' flag for record

    Thank you arlu1201!! This solution gets me much closer. It flagged every time the numeric code changed and the team name did not. Is there a way for the program to also flag where the team code is blank or has text filled in. It does not pick up on these changes. Please see the screen shot.
    teamcode is blank.jpg
    Any suggestions for these cases?
    Thanks again!

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to compare 2 columns cell contents and add 'Yes' flag for record

    Thats what i asked you in the bold section below my code. Should it consider the "Teamcode-blank" cells also and mark them Yes?

    So even if column C matches for the rows (for e.g. 12 to 14) and column D for these has the same text (no numbers), should they be flagged?

  5. #5
    Registered User
    Join Date
    12-06-2012
    Location
    Rochester, NY
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro to compare 2 columns cell contents and add 'Yes' flag for record

    Oh wow.. My apologies! My screen cut off right at that line. I did not see that. To answer your question. Yes, I also need to flag those records.
    Thank you!

+ 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