Avatar of morinia
morinia
Flag for United States of America asked on

putting a value in a formula based on what cell is "clicked" -- Excel 2010

Experts,

I would like to create an Interactive spreadsheet (see attached workbook), where if you click on any "A2 through A8" the value in that field will be used in the compare in H5 where "12345" is currently coded.

Can someone tell me how to do this?
Sample-XlS.xlsx
Microsoft ExcelVisual Basic ClassicVBA

Avatar of undefined
Last Comment
Rob Henson

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Wayne Taylor (webtubbs)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
morinia

ASKER
Wayne,

Is there a way to put just the value of the selected cell into H5 so I can use it for other things also.
I think I did this before but don't have access to the spreadsheet anymore  

The formula then uses the cake in H5.
Wayne Taylor (webtubbs)

Yes, use this instead...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)    
    If Not Intersect(Target, [A2:A8]) Is Nothing Then
        Range("H5").Value = Target.Value
    End If    
End Sub

Open in new window

Rob Henson

It is possible with formula as well.

In the cell where you want the specific value use formula:

=INDIRECT(ADDRESS(CELL("row"),CELL("col"),1,1))

initially this will give a Circular Reference but when you enter a value in another cell, on recalculation the cell with the formula will also get that value.

Thanks
Rob H
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes