Compare two workbooks and highlight matching cells

TOM R

Well-known Member
Joined
Oct 7, 2006
Messages
731
Hello Members,

I been trying to figure this out for about a week now reading into forums.

I have a work folder that contains about 300 .xls workbooks. Each excel workbook has a different name.
What I like to accomplish is to Open 2 workbooks. That vb would know what is open. If either one the workbooks has matching cells to highlight them vbyellow. cells C11 thru H19.

If any cell is blank do not highlight either them cells. Also, upon closing the workbooks return to original format for them cells. I thought I came cloe but this is over my head.

Any Members that can help with this feat I really could use the help.

Regards, Tom
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I failed to mention this will only be in sheet1 of both workbooks open.
 
Upvote 0
Hello, I can use a helping hand if possible. I been trying to get codes to work for me. but to no avail.

Without having to name the file in vb. Is it possilble to do this i dont know?
Also, the code below will highlight cells and not blanks. But its not good It will highlight non matching cells.


Code:
Private Sub Workbook_Open()
 Dim Rng As Range

  NewWorkbook = Application.GetOpenFilename( _
          FileFilter:="Excel 2003 (*.xls),*.xls,Excel 2007 (*.xlsx),*.xlsx,Excel 2007 (*.xlsm),*.xlsm", _
            Title:="Select an Excel File", _
            MultiSelect:=File)
    If NewWorkbook = False Then
        Exit Sub
    Else
        Workbooks.Open Filename:=NewWorkbook
    End If
    
     For Each Rng In Workbooks("RVHV-3DY_LEFT.xls").Worksheets(1).Range("D11:H19")
 If Rng.Value <> "" Then
 Rng.Interior.ColorIndex = 6 'Yellow
 End If
 Next Rng
 End Sub
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Rng As Range
          
     For Each Rng In Workbooks("RVHV-3DY_LEFT.xls").Worksheets(1).Range("D11:H19")
 If Rng.Value <> "" Then
 Rng.Interior.ColorIndex = 2 'Clear
 End If
 Next Rng
           
End Sub

Thanks in advance Tom
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,642
Members
449,325
Latest member
Hardey6ix

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top