ADDRESS of a RANGE

MLang

New Member
Joined
Dec 15, 2009
Messages
11
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).




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
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Use the Address property of the range. For example:
Code:
If Activecell.Address=Data_Corner_Marker.Address Then
'rest of code
 
Upvote 0
Perfect, and so simple.

I would have SWORN that I tried this, but I must have had something out of place...

Thank you!!!
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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