+ Reply to Thread
Results 1 to 6 of 6

VBA to highlight row based on duplicate cell from another sheet

  1. #1
    Registered User
    Join Date
    11-30-2007
    Posts
    5

    VBA to highlight row based on duplicate cell from another sheet

    Hello All!

    So I have a sheet full of info(sheet1) and another sheet(sheet2) with a single column of numbers. Some of these numbers will match numbers in Column B on sheet 1. I'm trying to get it to compare each number in column B with Column A on sheet 2 and if it finds a match highlight the entire row...I feel like the syntax is right aside from where I'm trying to set the Interior colorindex.

    It runs but but nothing happens. I was hoping for a little guidance.

    Thanks!


    Please Login or Register  to view this content.
    Last edited by Axis; 08-07-2016 at 10:37 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: VBA to highlight row based on duplicate cell from another sheet

    Why not just use Conditional Formatting?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: VBA to highlight row based on duplicate cell from another sheet

    Try this.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Registered User
    Join Date
    11-30-2007
    Posts
    5

    Re: VBA to highlight row based on duplicate cell from another sheet

    Quote Originally Posted by bakerman2 View Post
    Try this.
    Please Login or Register  to view this content.
    Works Perfect! Thanks!

    I'm not really sure what I did wrong...I guess I was looking at it from a standard visual basic view maybe? I ended up trying this before I saw your post...
    Please Login or Register  to view this content.
    Which didn't seem to work until I put a 1 in Sheet1 B2 and a 1 in Sheet2 A10....I ran that and it highlighted row 1....but nothing else...which told me I was close. However, when I debug stepped through the code it wasn't running like a normal nested loop. It should take Sheet1 B2 and then compare it to Each cell of Column A sheet 2 to check for a match until it hits the end of Column A, then it should move on to Sheet1 B3 and run through it again until it hits the end of Sheet1 ColumnB.....but when I step through it, it hits the nested loop, runs through the inner loop forever, then it moves to the outter loop and skips the inner loop until it ends.....which is not the way a nested loop works...so I'm not sure what the problem is, or if I did something wrong?

    Either way thanks for the assist!
    Last edited by Axis; 08-07-2016 at 11:03 PM.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: VBA to highlight row based on duplicate cell from another sheet

    First thanks for the rep points.

    You forgot to put the d back to it's starting value after completing the inner loop.
    Please Login or Register  to view this content.
    Because you didn't d keeps adding up instead of restarting from first row of column A in second sheet.

  6. #6
    Registered User
    Join Date
    11-30-2007
    Posts
    5

    Re: VBA to highlight row based on duplicate cell from another sheet

    Quote Originally Posted by bakerman2 View Post
    First thanks for the rep points.

    You forgot to put the d back to it's starting value after completing the inner loop.
    Please Login or Register  to view this content.
    Because you didn't d keeps adding up instead of restarting from first row of column A in second sheet.

    omg how did I miss that....

    Thanks

+ 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: 5
    Last Post: 05-27-2014, 07:23 AM
  2. Highlight duplicate rows based on column A but be case sensitive
    By theblade24 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-18-2013, 06:14 PM
  3. highlight duplicate data in another sheet
    By cauciu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2013, 08:36 PM
  4. [SOLVED] Highlight Duplicate Rows Based on Multiple Criteria
    By freybe06 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2013, 09:39 AM
  5. Highlight rows based on Duplicate with conditions
    By ypnOz in forum Excel General
    Replies: 5
    Last Post: 12-28-2010, 09:50 AM
  6. Highlight duplicate records based on multiple criteria
    By Beckiwi in forum Excel General
    Replies: 2
    Last Post: 06-11-2008, 03:53 PM
  7. Replies: 3
    Last Post: 06-26-2006, 06:10 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