Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Get the value of the selected cell- No VBA

0

Hey everyone, thanks for the great forum!
The solution I need must have no VBA involved.

How can I get the value (Context) of a selected cell?

Imagine I have names of the products in Column A (a1= book, a2 = pen , etc)
I want to turn each cell into a hyperlink that points to a different cell ( for example cell a1 in sheet2, all of them point to the same cell)
What I'd like to happen is after I clicked on Pen the "Pen" appears in the target cell ( sheet2!a1) and if I return to the first sheet and click on the book hyperlink the value "Book" appears in the target cell.
I also have office365 if that helps!

P.S: You can find the workbook in the attached file.

Thanks in advance

Answer
Discuss

Discussion

Hi Amin95 and welcome to the Forum.

Creating hyperlinks is pretty straightforward (in all versions of Excel) but without VBA they're only "one-way jumps".

If all you want do do is make Sheet2 cell A1 say Pen, enter that cell, type = then use your mouse to select Sheet1, click in  A2 (pen) and press Enter. Cell A1 will then have the formula
=Sheet1!A2
and show "Pen"

If this isn't what you want, I'm struggling to understand your question- is "... column A (a1= book, a2 = pen , etc)" on a different sheet to "target"? It nearly always help to see a sample file (and text showing what should happen to a cell so please edit your original question and use the Add Files... button to upload a representative Excel file (without any personal data) to show your existing data (and any macros). Then we should be able to give specific help.
John_Ru (rep: 6142) Oct 16, '23 at 12:13 pm
Hi John_Ru. Thanks for your response. I added the sample workbook and explained furthure in the workbook. Thanks for your time. Much appreciated.
amin95 (rep: 2) Oct 17, '23 at 2:31 am
Hi Amin 

Thanks for attaching your sample file. I now see what you want to do. I'm busy today but I can't think of a non-VBA way to do that. It would be easy with VBA - why don't you want to use it?
John_Ru (rep: 6142) Oct 17, '23 at 3:02 am
The final file will be uploaded on a website and for secuirity concerns the end users might not want to open an xlsm file. at least that's what my employer insists on. Anyway could you please provide me with the VBA code or even the xlsm file? I want to try to see if i can persuade my boss that this is the only way that this can be done. Thanks for your time.
amin95 (rep: 2) Oct 17, '23 at 3:08 am
Amin

I won't be at my PC for at least 6 hours but will provide an Answer (with file) to show how to do that with VBA. If each user saves a file for upload, I could add the VBA to save a. xlsx macro-free version, optionally including their user name in the filename BUT if users will access the file on the web, I can think if a way they can easily select an option (without VBA). Two questions - how many options will they have (your example had just 4)? Am I right to assume each user's choice should be stored against their name? 

Your part in the deal will be just to check the solution works and then mark the Answer as Selected - that's all I get for my effort (but new Forum users often fail to do that sadly).
John_Ru (rep: 6142) Oct 17, '23 at 3:38 am
Thanks Yes I can wait.  no the number of items is going to be much more and there will be no need to see the username of the users. This file is going to be like a report. the functionality I am looking for, is like the drill through feature in Power BI. For example when the user clicks on Magazines the sheet2!a1 will be magazine and the user will see information about magazines. So the sheet2!a1 cell will be like a dynamic variable that other formulas get it for a part of their input.   and then when the user goes back to sheet1 and clicks on another product, they will see the information about the newly selected product in sheet2 ( so in other words the value of cell a1 in the sheet 2 will be overwritten each time the user clicks on that product)  And for the final part of your reply, Yes Absolutely this is the least I can do for your help. I will surely mark it as Selected. Thanks
amin95 (rep: 2) Oct 17, '23 at 5:57 am
Add to Discussion

Answers

0
Selected Answer

Amin

Here's a non-VBA solution which should work. It uses a hyperlink to jump to page 2 where cell A1 will show the value of (yellow) cell A3 sheet 1 (Select a product) and I assume you will extract a report based on that.

It uses data validation and the CELL function. Cell A3 has List data validation based on the table ("Products") from cell L3 down (which can easily be extended). The validation formula is:

=INDIRECT("Products[Product list]")

where INDIRECT points to the data in that table.

Cell A3 then has a dropdown list, by which you can pick a product. It also has a single hyperlink which points to cell A1 of sheet 2 ("Report") where the formula is:

=CELL("contents",'Select a product'!A3)

where the bold part tells Excel to show what's in the non-bold second argument i.e. A3. on the other sheet. The first argument of CELL ("contents") is one of the "info-types" that can be used by this function.

(Revision 17 Oct 2023: in fact you don't need CELL here, You can just use = and point to A3 on the other sheet as usual. It's in my file since I was initially using the HYPERLINK function to point to one of several sheets).

From there I assume you will provide the detail needed on sheet 2 (via Power BI or whatever).. Note that cell G1 has a hypelink to jump back to the product select sheet.

Another alternative is a solution I posted before where buttons are used to navigate to individual sheets, see Viewing Excel Workbook on a website. (A similar apporach is possible for many items but using hyperlinking and CELL, without buttons). 

Hope this fixes your problem. If so. please remember to mark this Answer as Selected.

Discuss

Discussion

Hi John_Ru Thanks for your reply. This gave me a good insight to solve my problem. Thank you for your help. Have a nice day
amin95 (rep: 2) Oct 17, '23 at 12:27 pm
Thanks for selecting my Answer, Amin. Good luck with your "real world" implememtation.
John_Ru (rep: 6142) Oct 17, '23 at 12:36 pm
Just added a Revision, to simplify the approach 
John_Ru (rep: 6142) Oct 17, '23 at 2:54 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login