I want to learn how to compare the ADDRESSES of RANGES (as opposed to the VALUES in those ranges...)
I am able to FIND a cell with a certain value. I save this active cell as a range. Then I look for the NEXT cell with that certain value. Once I find it, I try to determine if I am still on the same cell (meanign there was not really a next cell...).
I figured I would just check if the range of the active cell is the same as the previous range I saved. Unfortunately, it is evaluaitng the values in the range (from what I can tell).
I am able to FIND a cell with a certain value. I save this active cell as a range. Then I look for the NEXT cell with that certain value. Once I find it, I try to determine if I am still on the same cell (meanign there was not really a next cell...).
I figured I would just check if the range of the active cell is the same as the previous range I saved. Unfortunately, it is evaluaitng the values in the range (from what I can tell).
Code:
Sub Find_Data_Corner_Marker()
'Find the cell named 'Data Corner', and make sure that there is only one such cell.
Dim DATA_CORNER_MARKER_RANGE As Range
'Find the first DATA_CORNER_MARKER
'start in cell A1
Range("A1").Select
'Do a FIND
Cells.Find(What:=DATA_CORNER_MARKER, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'Store the Range Address
Set DATA_CORNER_MARKER_RANGE = Range(ActiveCell, ActiveCell)
'CHECK FOR NO MARKERS
If ActiveCell <> DATA_CORNER_MARKER Then
ANSWER = "None"
'CHECK FOR MULTIPLE MARKERS
Else
Cells.FindNext(After:=ActiveCell).Activate ' look for another
If DATA_CORNER_MARKER_RANGE <> Range(ActiveCell, ActiveCell) Then
ANSWER = "Multiple"
'MUST BE ONE MARKER!
Else
ANSWER = "One"
End If
End If
'Let me know
MsgBox ANSWER & " : DATA_CORNER_MARKER_RANGE = Row: " & Selection.Row & "; Col: " & Selection.Column
End Sub