VBA retrieving row and column info from user supplied range(s)

F

fracture

I have a relatively simple macro where the user supplies two cel
ranges, the cell data of which is then compared between the two range
and any unique values from either range reported on.

What I'm trying to do is correlate the original column and row with th
unique cell that has been identified.
The macro captures the row and column counts and has a simple for nex
loop to check each cell within the two ranges. Therefore I can repor
on the column and row value 'within' the range itself but not th
actual column and row.

For example if one supplied range was D10:E20 and if cell E10 wa
identified as unique it captures this as 1,2. How can I reference thi
against the original range so it will report as D10?

Thanks in advance and forgive my ignorance
 
T

Tom Ogilvy

From the immediate window for illustration:

? Range("D10:E20")(1,2).Address
$E$10
 
F

fracture

Many thanks for the prompt reply Tom ;) , I can see how this would wor
but with my limited exposure to VBA I'm struggling to structure th
appropriate code:

For reference:
- the first address range is contained within variable rng1
- the second address range is contained within variable rng2
- the captured row is r1 for unique data
- the captured column is c for unique data

I'm assuming that the original cell is returned as a string therefor
j2o has been assigned.

I envisaged that:

j2o = rng1.address(r1,c)
or
j2o = rng2.address(r1,c)

Would provide the relevant cell but I'm just getting the entire rang
back.

Any pointer
 
T

Tom Ogilvy

for which ever range the r1 and c apply to

j2o = rng1(r1,c).Address

or

j2o = rng2(r1,c).address
 
Top