From a value found with XLOOKUP, retrieve the cell's address

Rubens Sayegh

New Member
Joined
Sep 4, 2021
Messages
2
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Greetings!
I am using VBA in Excel and with the following function...

Dim BZIT as Double
BZIT = Application.WorksheetFunction.XLookup(Cells(LIN, COL).Value, Range("C:C"), Range("G:G"), , 1)


I get the value in cell LIN,COL, find it (or the next one to it) in column C, then jump in the same line, to column G and get the cell's value.
See this example:

Assuming that the cell in position (LIN, COL) has a value of 1.765, then...

Column C...Column G
Line 11.000...0.222
Line 22.000...0.345
Line 33.000...0.658
Line 44.000...0.999

So, XLOOKUP picks 1.765 and try to match it in column C.
As there's no match, the next number (2.000, in line 2) is choosen.
In the same line, "jumping" to column G, the function returns in BZIT the value 0.345 - Presto! -

But, what I really need is the cell's address (where the 0.345 is).
I've tried using ActiveCell.Address(False, False) but this only returned the address of the cell where the cursor was positioned, and not the address of the result's cell...

Any help would be greatly appreciated.
Thanks in advance.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I can't test it at the moment but based on my understanding of how xlookup works, if you put a string data type variable on the left of your equals sign and append ".Address" without quotes to the end of your Xlookup, you should get the address.
PS: now tested and confirmed
 
Last edited:
Upvote 0
In case you need it:-
VBA Code:
Dim addrBZIT As String
addrBZIT = Application.WorksheetFunction.XLookup(Cells(LIN, COL).Value, Range("C:C"), Range("G:G"), , 1).Address
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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