Your desired functionality can be achieved without VBA. Let's build the sheet step by step:
We need the value for the dropdown that will show up in A1.
As you already wrote, there is a sheet (I name it roster
).
Here we enter the value for the dropdown and in the cell right next
to it the desired address where you want to get the data from:
| A | B |
+--------+-----------+
1 | Name_1 | Sheet2!C6 |
2 | Name_2 | Sheet2!C7 |
3 | Name_3 | Sheet2!C8 |
Go to Cell A1
and set the validity to "Allow cell range" and set the cell range to roster.$A$1:$A$3
. You now have the dropdown.
As the next step, let's enter the value in Sheet2: go to Sheet2
and enter the value to retrieve (I just use some stupid texts :-) )
| A | B | C |
+----+----+-------+
6 | | | Alpha |
7 | | | Beta |
8 | | | Gamma |
Now for the interesting part: how to display the values depending on your dropdown selection? We use a combination of Indirect()
and VLookup()
:
Go to your cell F34
and enter the formula below:
=INDIRECT(VLOOKUP(A1,roster.$A$2:$B$6,2,FALSE()))
What's going on?
- The inner part
VLookup()
, searches for the value of A1
in the
matrix where we defined the valid vlaues and the addresses for the
data, takes the second column (the addr) and retrieves it. So if
you have "Name_2" in the dropdown, this function will return Sheet2!C7
- The outer part uses this address via the
Indirect()
function to
retrieve from this address (who said Excel doesn't know Pointers),
so you get the text "Beta".
So all we need is a matrix with valid value, the addresses of the data to retrieve and a single formula. Hope that answers your question, though I'm a bit late to the party, if I look at the timestamp. :-)