+ Reply to Thread
Results 1 to 6 of 6

Loop through workbook and compare the columns

  1. #1
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Loop through workbook and compare the columns

    Hi everyone,

    I'm trying to loop through a workbook with multiple sheets, and compare the same columns in the whole workbook and highlight the difference.

    What I want to achieve is to check everything in column B and C, Column B is delivery date and C is the id. I want to make sure that similar id hasn't been input a different delivery date.

    For example In the workbook if there's a sheet with same id has a delivery date and on another sheet it has a different delivery date then highlight all in the same id in C in the whole workbook.
    Attached Files Attached Files

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Loop through workbook and compare the columns

    Your attached file bears no resemblance to your narrative and your narrative is not clear on what you want highlighted. Maybe if you can clearly define what you want, someone can assist.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Loop through workbook and compare the columns

    Quote Originally Posted by JLGWhiz View Post
    Your attached file bears no resemblance to your narrative and your narrative is not clear on what you want highlighted. Maybe if you can clearly define what you want, someone can assist.
    Apologised, I'd attached a wrong example
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Loop through workbook and compare the columns

    Here's a way to accomplish this using a dictionary - note that you will have to enable Microsoft Scripting Runtime (under Tools > References). Also, this loops through all the sheets in the active workbook - if you have some that should not be examined, the sheet reference will need to be changed.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-02-2018
    Location
    england
    MS-Off Ver
    2016
    Posts
    156

    Re: Loop through workbook and compare the columns

    Quote Originally Posted by danielexcelvba View Post
    Here's a way to accomplish this using a dictionary - note that you will have to enable Microsoft Scripting Runtime (under Tools > References). Also, this loops through all the sheets in the active workbook - if you have some that should not be examined, the sheet reference will need to be changed.
    Please Login or Register  to view this content.
    Hi danielexcelvba

    I try the code on the main workbook there's a run time error. I can't post the main workbook on here but the example workbook for the 2 columns are the same as he main workbook the only differences is that the main workbook has 200+ sheets.

  6. #6
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Loop through workbook and compare the columns

    The number of sheets could be an issue. Seeing as you can't post the real workbook, you'll have to edit this slightly.
    Please Login or Register  to view this content.
    If you change the bolded code to an array of the sheet names you want to search it should work.

+ 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. loop through files find columns and copy/paste them as columns in master workbook
    By Michal1111 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2018, 10:40 PM
  2. [SOLVED] Compare and copy two columns from each sheet in a workbook
    By sarajun_88 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-01-2018, 08:25 AM
  3. [SOLVED] VBA - Loop - Compare data of two columns & copy unmatched to specific place one by one
    By laiqkhan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-22-2014, 01:07 AM
  4. Replies: 1
    Last Post: 06-23-2011, 04:22 PM
  5. Compare two columns in one woorkbook, bounce results off of a different workbook.
    By goldenr1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2010, 12:19 AM
  6. [SOLVED] Loop Down Columns and Compare Values
    By DrwRob28 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-15-2006, 01:25 PM
  7. Compare columns in 2 sheets in the same workbook and copy HELP NEEDED
    By ktab in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2005, 08:23 AM

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