+ Reply to Thread
Results 1 to 4 of 4

Match and color cells if same value cell in other sheet detected

Hybrid View

  1. #1
    Registered User
    Join Date
    08-20-2015
    Location
    Lithuania
    MS-Off Ver
    2010
    Posts
    2

    Match and color cells if same value cell in other sheet detected

    Hello everyone,

    I'm trying to make macros which will find and color particular cells which have the same value as cells in other sheet.

    I have two different sheets - 1st one smaller (~500 rows with several columns) and 2nd sheet with ~60000 rows and more columns. I need to make a macros that will check if the cell value (ten digit number) in the 1st sheet is mentioned in 2nd sheet - if yes, the cell in the 1st sheet should be filled in red.

    In the first sheet column with those ten digit numbers is C. In the 2nd sheet - B.

    This macros should be triggered with some keyboard combination.

    I tried using conditional formatting, but it doesn't work for me... Maybe you could help me?

    Thanks!

  2. #2
    Registered User
    Join Date
    08-05-2015
    Location
    Finland
    MS-Off Ver
    Home and Business 2013
    Posts
    50

    Re: Match and color cells if same value cell in other sheet detected

    Hello Dempix.

    Sub Dempix()
    Application.ScreenUpdating = False
    
    Sheets("Sheet2").Activate   'RENAME SHEET 2
    Set Rng = Range(Cells(1, 2), Cells(1, 2).End(xlDown))
    Sheets("Sheet1").Activate   'RENAME SHEET 1
    For Each cell In Range(Cells(1, 3), Cells(1, 3).End(xlDown))
    Set Fcell = Rng.Find(What:=cell.Value, LookIn:=xlValues, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)
    If Not Fcell Is Nothing Then
    cell.Interior.Color = 255
    Else
    'SKIP
    End If
    Next cell MsgBox "All done!" Application.ScreenUpdating = True End Sub
    NOTE! Rename sheets in code. In excel go to developer tab, click on "Macros" select this macro and click on "Options", select prefered keyboard shortcut to run the macro.

  3. #3
    Registered User
    Join Date
    08-20-2015
    Location
    Lithuania
    MS-Off Ver
    2010
    Posts
    2

    Re: Match and color cells if same value cell in other sheet detected

    Many many thanks The_Greg! It works perfectly!

    Is it possible to adjust the macros that it would work this Sheet 2 placed in different location/file:
    For example, Sheet 2 is stored at S:\Folder\file.xlsx sheet name
    ?

  4. #4
    Registered User
    Join Date
    08-05-2015
    Location
    Finland
    MS-Off Ver
    Home and Business 2013
    Posts
    50

    Re: Match and color cells if same value cell in other sheet detected

    Hello Dempix, here is the modified code.

    Sub Dempix()
    Application.ScreenUpdating = False
    
    Dim MainWB As String
    MainWB = ActiveWorkbook.Name
    
    Workbooks.Open ("S:\Folder\file.xlsx")  'RENAME FILE HERE
    
    Sheets("Sheet2").Activate   'RENAME SHEET 2
    Set Rng = Range(Cells(1, 2), Cells(1, 2).End(xlDown))
    Workbooks(MainWB).Sheets("Sheet1").Activate   'RENAME SHEET 1
    
    For Each cell In Range(Cells(1, 3), Cells(1, 3).End(xlDown))
        Set Fcell = Rng.Find(What:=cell.Value, LookIn:=xlValues, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
        If Not Fcell Is Nothing Then
            cell.Interior.Color = 255
        Else
            'SKIP
        End If
    Next cell
        
    Workbooks("file.xlsx").Close    'RENAME FILE HERE OR REMOVE THIS LINE
        
    MsgBox "All done!"
    Application.ScreenUpdating = True
    End Sub

+ 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. Keep deleting row until row with color is detected.
    By zoenightshade in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2015, 07:25 PM
  2. [SOLVED] Change color of row if part is detected in column A
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2015, 12:31 PM
  3. [SOLVED] Find The Match For All The Cells From A Range In Another Sheet And Use Their Color
    By taccoo73 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-25-2014, 10:45 AM
  4. Match cell color in two cells
    By iggypop in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-16-2013, 05:26 AM
  5. Replies: 5
    Last Post: 02-21-2013, 07:17 PM
  6. Replies: 12
    Last Post: 09-18-2012, 03:13 PM
  7. [SOLVED] sum all cells in a row until first cell with a zero is detected
    By Chubster in forum Excel General
    Replies: 9
    Last Post: 03-20-2012, 06: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