Highlight differences of values in two named ranges

Zak Naz

New Member
Joined
Jan 12, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Need a VBA to select and open two workbooks containing the same defined names, however, different with ranges, then, highlight in one of the workbooks the differences of contents for every named range.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
This is a sample of the contents of each file with named ranges

Report
.
PROJECT:KERP South Kuwait Excavation, Transportation, RemediationSTAGE: 3.1, 3.2
Schedule
MilestoneCurActFor
A24-Apr-1025-Apr-17-
B10-Apr-1831-Mar-09
C21-Aug-0815-Dec-09
D15-Nov-02
E10-Apr-1412-Mar-20
F11-Apr-1913-Mar-20
G26-Mar-22gfgfgJul-15
H26-Mar-23ggyug
I24-Jun-23
ACTIVITIES:
AAA
VVVVV
GGGGG
LLLLL
ZZZZZZZZZZZZZZ
DDDDDDDDDDDDDD
BBBBBBBBBBBBBBBBBBB
OUTSTANDING:
TTTTTTTTTTTT
Action
jgfjgfjgf
iytityuyt
Dates
Stage GateSTATClsForec
1.0-A21-Oct-08
2.0- B31-Jan-30
3.1- CJan-20
3.2- DMar-20
4.0- EJul-15
5.0- F
 
Upvote 0
The following macro is working as expected, however, for comparing two named ranges on the same sheet. What I need is to compare ALL named ranges on two different workbooks that both have identical named ranges.

Sub CompareRanges()
Dim rangeToUse As Range, singleArea As Range, cell1 As Range, cell2 As Range, i As Integer, j As Integer

Set rangeToUse = Range("sheet1!Ongoing_ACTIVITIES,sheet1!Outstanding_ACTIVITIES")

'Cells.Interior.ColorIndex = 0
rangeToUse.Interior.Color = vbYellow

'rangeToUse.Interior.ColorIndex = 6

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 = 0
cell2.Interior.ColorIndex = 0
End If
Next cell2
Next cell1
Next j
Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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