Forum Discussion
How to calculate an array from different columns
- Jul 24, 2021
Assuming Headers are sequential numbers this one
=SUMPRODUCT(INDEX(B2:F2,1,FILTERXML("<y><z>"&SUBSTITUTE(B4,",","</z><z>")&"</z></y>","//z")))also shall work on 2019
Assuming Headers are sequential numbers this one
=SUMPRODUCT(INDEX(B2:F2,1,FILTERXML("<y><z>"&SUBSTITUTE(B4,",","</z><z>")&"</z></y>","//z")))
also shall work on 2019
If I enter 1,4,5 in B4, it does not calculate the new query.
- SergeiBaklanJul 24, 2021Diamond Contributor
- KonfytJul 25, 2021Copper Contributor
Hi there,
I have asked the question on another forum (chandoo.org) regarding the problem with CTRL+SHIFT+ENTER issue we encountered and received this change which solved that issue. I thought I would share it with you as you have really helped me a lot:
=SUMPRODUCT(INDEX(B2:F2,1,N(IF(1,FILTERXML("<y><z>"&SUBSTITUTE(B4,",","</z><z>")&"</z></y>","//z")))))
Here is yours for quick reference. It seems the only difference is the N(IF addition.
=SUMPRODUCT(INDEX(B2:F2,1,FILTERXML("<y><z>"&SUBSTITUTE(B4,",","</z><z>")&"</z></y>","//z")))
Thank You again SergeiBaklan
- KonfytJul 25, 2021Copper Contributor
This is how things look when I open your sheet. After each try, I have closed the sheet and opened the original received from you. I did not save after each try.
1. This is a screenshot after I changed the content of B4 to 1,4,5 then pressing CTRL+SHIFT+ENTER
2. This is the screenshot after changing the content of B4 to 1,4,5 then pressing only ENTER.
I have tried it on another laptop using 2016 Pro Plus and another using 2016 as well.
I am not sure if there are any settings that I need to change or that we are still doing it wrong on our side. it is my First time using Array and VBA.
Thanks in advance Sergei.