I have the below piece of code and i want to start adding more named ranges like "Today" and "Yesterday"
How can i add on to that code
e.g. my next named ranges would be "MeritToday" & "Merit Yesterday"
Public Sub CompareData()
'compares Today and Yesterday named ranges
Dim rngToday As Range
Dim rngYesterday As Range
Dim rngTcell As Range
Dim boolFirstTime As Boolean
Set rngToday = ActiveSheet.Range("Today")
Set rngYesterday = ActiveSheet.Range("Yesterday")
If (rngToday.Columns.Count = rngYesterday.Columns.Count) _
And (rngToday.Rows.Count = rngYesterday.Rows.Count) Then
MsgBox "Sophis Fiscal are Identical!", vbCritical, "Range size difference"
boolFirstTime = True
For Each rngTcell In rngToday
If rngTcell.Value <> rngYesterday.Cells(rngTcell.Row - rngToday.Row + 1, rngTcell.Column - rngToday.Column + 1).Value Then
If boolFirstTime Then
boolFirstTime = False 'skip header cell
MsgBox "Data Identical", vbCritical, "Range Data Identical"