Rubens Sayegh
New Member
- Joined
- Sep 4, 2021
- Messages
- 2
- Office Version
- 365
- 2016
- Platform
- 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...
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.
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 1 | 1.000 | ... | 0.222 |
Line 2 | 2.000 | ... | 0.345 |
Line 3 | 3.000 | ... | 0.658 |
Line 4 | 4.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.