=INDIRECT to return intersection of ActiveCell row and specific Column

2Took

Board Regular
Joined
Jun 13, 2022
Messages
203
Office Version
  1. 365
Platform
  1. Windows
On Worksheet_SelectionChange in L1 I have VBA populate ActiveCell.Address

VBA Code:
Range("L1").Value = ActiveCell.Address

Trying to figure out a formula, by using value in L1, to return intersection of ActiveCell Row and specific Column.

I believe =INDIRECT formula might be a way to get it done, something along the lines of =INDIRECT(L1&"H"), but that's not quite it, gives #REF!

L1 shows references this way: $G$11
In that example 11 is the ActiveCell Row, guessing needs to be extracted and "H" added to it...
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
To clarify, I need to have contents/value of resulting cell address returned, e.g. if cell H11 value is "ABC123" I want to see that showing in a cell where the formula I am trying to figure out is going to be at.

I got formula below so far, which combines H and the ActiveCell Row reference stripped from L1, which returns everything after the last occurrence of "$" in L1.

="H" & RIGHT(L1,LEN(L1)-SEARCH("#",SUBSTITUTE(L1,"$","#",LEN(L1)-LEN(SUBSTITUTE(L1,"$","")))))

But, result I am seeing in a cell with this formula is literally "H11", whereas I'd like to see the contents/value of H11, which is "ABC123"
 
Upvote 0
I knew I was almost there :)

Solution is to wrap it in =INDIRECT("H" & RIGHT(L1,LEN(L1)-SEARCH("#",SUBSTITUTE(L1,"$","#",LEN(L1)-LEN(SUBSTITUTE(L1,"$",""))))))
 
Upvote 0
Whilst that will work ...
  1. Why not have the worksheet change code directly put the result in whatever cell you have this volatile function formula in?

  2. If you really want to use a formula, what about this much simpler one
    Excel Formula:
    =INDIRECT("H"&TEXTAFTER(L1,"$",-1))

  3. Or if the user(s) do not have the TEXTAFTER function, one of these
    Excel Formula:
    =INDIRECT("H"&REPLACE(L1,1,FIND("$",L1,2),""))
    Excel Formula:
    =INDIRECT("H"&MID(L1,FIND("$",L1,2)+1,7))
 
Upvote 0
Whilst that will work ...
  1. Why not have the worksheet change code directly put the result in whatever cell you have this volatile function formula in?

  2. If you really want to use a formula, what about this much simpler one
    Excel Formula:
    =INDIRECT("H"&TEXTAFTER(L1,"$",-1))

  3. Or if the user(s) do not have the TEXTAFTER function, one of these
    Excel Formula:
    =INDIRECT("H"&REPLACE(L1,1,FIND("$",L1,2),""))
    Excel Formula:
    =INDIRECT("H"&MID(L1,FIND("$",L1,2)+1,7))
Thanks,

Simplest one is actually
Excel Formula:
=ROW(INDIRECT(L1))
 
Upvote 0
Simplest one is actually
Excel Formula:
=ROW(INDIRECT(L1))
That of course is only part of the final formula, and I'm not sure that those two function calls to get the row number are simpler than the single function ..
Excel Formula:
TEXTAFTER(L1,"$",-1)


Simpler again would be to have your selection change code as
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Range("L1").Value = "H" & ActiveCell.Row
End Sub
Then all you would need is
Excel Formula:
=INDIRECT(L1)

.. or if you might be referencing several different columns with different INDIRECT functions then
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Range("L1").Value = ActiveCell.Row
End Sub
Excel Formula:
=INDIRECT("H"&L1)+INDIRECT("X"&L1)
 
Upvote 0
Solution
First one uses unavailable formula.
Second would require to go to VBA to adjust column.
The latter one is the most streamlined, with the exception of formula does not take "+", takes "&"

Thank you, I always learn from you :)
 
Upvote 0
with the exception of formula does not take "+", takes "&"
That was just an example and depends on the data in the columns. The formula works fine with "+" if the data in the two columns is numerical. Since we didn't know if you might want to reference two (or more) columns and we have no idea of what your data is, I took a guess to demonstrate the principle. ;)

For the sheet below my selection change uses the last one in my previous post to return only the active cell row to L1.
Formula in M1 is =INDIRECT("H"&L1)+INDIRECT("X"&L1) and you can see with the active cell in P6 the M1 formula works.

1666042554717.png
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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