Dynamic Match()/Index() (col changing)

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I want to make my match() and Index() look more dynamic.
User is going to select name from a Data validation list
Then user will Select from another data validation list to tell excel what they want to return, Phone#, Address, or Salary

I can do the lookup if the column is fixed (col1, 2, 3) like the following

=INDEX($A$1:$D$20,MATCH($H$5,$A$1:$A$20,0),2)

That is to return phone# but I like to make it dynamic, I do not want to pass col2 to Index function. Is that possible? Thank you.

[TABLE="class: grid, width: 137"]
<tbody>[TR]
[TD]select name[/TD]
[/TR]
[TR]
[TD]john16[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]enter what you want[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="class: grid, width: 256"]
<tbody>[TR]
[TD="width: 64"]name[/TD]
[TD="width: 64"]ph#[/TD]
[TD="width: 64"]address[/TD]
[TD="width: 64"]salary[/TD]
[/TR]
[TR]
[TD]john1[/TD]
[TD="align: right"]1[/TD]
[TD]1 main st[/TD]
[TD="align: right"]2472[/TD]
[/TR]
[TR]
[TD]john2[/TD]
[TD="align: right"]2[/TD]
[TD]2 main st[/TD]
[TD="align: right"]8646[/TD]
[/TR]
[TR]
[TD]john3[/TD]
[TD="align: right"]3[/TD]
[TD]3 main st[/TD]
[TD="align: right"]1156[/TD]
[/TR]
[TR]
[TD]john4[/TD]
[TD="align: right"]4[/TD]
[TD]4 main st[/TD]
[TD="align: right"]9592[/TD]
[/TR]
[TR]
[TD]john5[/TD]
[TD="align: right"]5[/TD]
[TD]5 main st[/TD]
[TD="align: right"]2862[/TD]
[/TR]
[TR]
[TD]john6[/TD]
[TD="align: right"]6[/TD]
[TD]6 main st[/TD]
[TD="align: right"]2155[/TD]
[/TR]
[TR]
[TD]john7[/TD]
[TD="align: right"]7[/TD]
[TD]7 main st[/TD]
[TD="align: right"]4604[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try this formula

Excel Workbook
ABCDEFGHIJ
1nameph#addresssalary
2john111 main st2472
3john222 main st8646
4john333 main st1156
5john1address1 main st
Hoja12
 
Upvote 0
If in H7 you put a list where user can select Phone, Address or Salary then

Code:
=INDEX($A$1:$D$20,MATCH($H$5,$A$1:$A$20,0),IF($H$7="Phone",2,IF($H$7="Address",3,4)))
 
Last edited:
Upvote 0
withdrawn...Dante has it covered
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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