Highlight missing data from two named ranges in two different workbooks

Zak Naz

New Member
Joined
Jan 12, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello Experts,
Need you assistance to use the below code (or similar approach) to perform the following tasks:
1- Ask to open two workbooks.
2- For each identical sheet name in both workbooks compare contents of each cell in identical named ranges (areas will not be equal and may contain merged cells) and highlight missing contents in both sheets.

VBA Code:
Sub HighlightMissingData()
Dim rangeToUse As Range, singleArea As Range, cell1 As Range, cell2 As Range, i As Integer, j As Integer
Dim SelectionOne As Range, SelectionTwo As Range, WS1 As Worksheet, WS2 As Worksheet

Application.ScreenUpdating = False

ActiveWorkbook.Worksheets("Sheet1").Activate
Range("Workbook1.Sheet1!Ongoing_Activities, Workbook2.Sheet1!Ongoing_Activities").Select

Set rangeToUse = Selection

Cells.Interior.ColorIndex = xlNone

If rangeToUse.Areas.Count <= 1 Then
      MsgBox "Please select more than one area."
Else

rangeToUse.Interior.Color = vbYellow

    For i = 1 To rangeToUse.Areas.Count
        For j = i + 1 To rangeToUse.Areas.Count
            For Each cell1 In rangeToUse.Areas(i)
                    For Each cell2 In rangeToUse.Areas(j)
                        If cell1.Value = cell2.Value Then
                            cell1.Interior.ColorIndex = xlNone
                            cell2.Interior.ColorIndex = xlNone
                        End If
                        Next cell2
                Next cell1
            Next j
        Next i

End If
End Sub

Also asked here https://www.myonlinetraininghub.com...m-two-named-ranges-in-two-different-workbooks
 
Last edited by a moderator:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,872
Messages
6,122,026
Members
449,061
Latest member
TheRealJoaquin

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