Changing column index number in Vlookup

Dwyane

New Member
Joined
Nov 7, 2022
Messages
12
Office Version
  1. 2021
Platform
  1. Windows
I have number arranged horizontally at the bottom of my spreadsheet and below looksup their percentage value. I want it to be more dynamic. I want the column index number to change if the last value in column A changes. In my example, it should show me 50% 50% because the last number is 0 which belongs to group2(column L). if the last number in column A was say 12,or any number from group 1 then the below lookup would ok.
Excel Formula:
VLOOKUP(I15,$H$2:$N$9,4)[/CODE
]
 

Attachments

  • mrexec_4.png
    mrexec_4.png
    61.1 KB · Views: 21

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How should Excel suppose to know if 0 belongs to Colum L since there is no 0 value in that column?
 
Upvote 0
This is my understanding:
1) Percentage
Percentage1 applies if the number is contained in the brackets of group 1 being (22,12,13)
Percentage2 applies if the number is contained in the brackets of group 2 being (2,4,0)
I think you would need a mapping table to support that as shown below.
2) You want to look up the last item entered in Column A

The internal Index-XMatch get the cell with data in column A
The Next Vlookup get the Group no from the Code-Group mapping Table
This converts to "Percentage" & group no (1 or 2)
The next Match gets the column for the Percentage 1 or 2
The outer Vlookup gets the percentage you are after.

20221111 Vlookup Index Match Dwyane.xlsx
ABGHIJKLMNOPQ
122numgroup 1(22,12,13)count1Percentage1group 2(2,4,0)count2Percentage2CodeGroup
213133%50%221
312233%121
4123131
52433%22
64550%42
70602
87
98
10
11
12
13
14
1512345678
1650%0%0%0%50%0%0%0%
Data
Cell Formulas
RangeFormula
I16:P16I16=VLOOKUP(I$15,$H$2:$N$9,MATCH("Percentage" & VLOOKUP(INDEX($A$1:$A$10,XMATCH(TRUE,$A$1:$A$10<>"",0,-1),0),$P$2:$Q$7,2,FALSE),$H$1:$N$1,0),FALSE)
 
Upvote 0
Solution
How should Excel suppose to know if 0 belongs to Colum L since there is no 0 value in that column?
This formula goes into column L
Excel Formula:
IFERROR(FILTER(G1:G8,(A1:A8=2)+(A1:A8=4)+(A1:A8=0)),"")
. It looks up values in G if the value in column A is 0,4 or 2. So since zero is the last number in A, the column index should dynamically change to 7 which is the column for percentage 2
 
Upvote 0
This is my understanding:
1) Percentage
Percentage1 applies if the number is contained in the brackets of group 1 being (22,12,13)
Percentage2 applies if the number is contained in the brackets of group 2 being (2,4,0)
I think you would need a mapping table to support that as shown below.
2) You want to look up the last item entered in Column A

The internal Index-XMatch get the cell with data in column A
The Next Vlookup get the Group no from the Code-Group mapping Table
This converts to "Percentage" & group no (1 or 2)
The next Match gets the column for the Percentage 1 or 2
The outer Vlookup gets the percentage you are after.

20221111 Vlookup Index Match Dwyane.xlsx
ABGHIJKLMNOPQ
122numgroup 1(22,12,13)count1Percentage1group 2(2,4,0)count2Percentage2CodeGroup
213133%50%221
312233%121
4123131
52433%22
64550%42
70602
87
98
10
11
12
13
14
1512345678
1650%0%0%0%50%0%0%0%
Data
Cell Formulas
RangeFormula
I16:P16I16=VLOOKUP(I$15,$H$2:$N$9,MATCH("Percentage" & VLOOKUP(INDEX($A$1:$A$10,XMATCH(TRUE,$A$1:$A$10<>"",0,-1),0),$P$2:$Q$7,2,FALSE),$H$1:$N$1,0),FALSE)
Hello Mr. Blakenburg,
I am intrigued by how this works perfectly. Still reading to get a better understanding. Thank you very much
 
Upvote 0
You're welcome. Glad we could help.
Let me know if you have questions on how it works.
I forgot to mention that the XMatch has the parameter set (-1) to start looking from the bottom up.
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

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