Index formula, can the column number be dynamic?

Tirrazo

New Member
Joined
May 19, 2022
Messages
19
Office Version
  1. 365
Platform
  1. Windows
I need help to set the column number for the index formula automatically instead of static.

The formula is used in combination with LET-function and the array that this creates are returning different values.
If I would like to increase the number of columns because I want more data within the area the formula is looking, I have to manually count the columns and enter it.
I have many if the same formulas so this takes a lot of time.

In the example I am using column 1,3,4,6 that I am getting data back from.
 

Attachments

  • Index formula.PNG
    Index formula.PNG
    12.5 KB · Views: 12
  • Area.PNG
    Area.PNG
    5.9 KB · Views: 11
  • 1 3 4 6.PNG
    1 3 4 6.PNG
    6.6 KB · Views: 10
in order for the index to create a cell reference instead of value you need to preceed or follow the index portion of the function with a ":" and the cell reference that is on the other end. I don't that in your formula? can you explain in words what youre trying to do?
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
in order for the index to create a cell reference instead of value you need to preceed or follow the index portion of the function with a ":" and the cell reference that is on the other end. I don't that in your formula? can you explain in words what youre trying to do?
Can you try to use my formula and insert it with the correct Index reference?
I am not sure how to do it
 
Upvote 0
Please post 10-20 rows of examples comparing the worksheet results you have with what you want using xl2bb?
 
Upvote 0
but, say you have a range of A1:Z50... and you know you want to start in cell A5 and go to the first cell that has a value of 100 in it (assume there is no 100 in cells A1:A5:
the calculation to create that range is: A5:INDEX(A1:A50,Match(100,A1:A50,0) (In this simple example you could even say Match(100,A5:A50,0) in the middle of the index statement.
 
Upvote 0
Testark.xlsm
UVWXYZAAABACADAEAFAGAH
18
1964.6015.04.2021CAD 0.1014.03.202228.04.2022
2091.2001.03.2021CAD 0.1014.02.202202.03.2021
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37Fra datoTil datoFra datoTil dato
3801.03.202131.03.202201.04.202130.04.2021
39
40TickerSumBeregnetEXTickerSumBeregnetEX
41ENBkr 91.2001.03.202114.02.2022BCEkr 64.6015.04.202114.03.2022
42
43
44
45
46
47
Utbk
Cell Formulas
RangeFormula
AB19AB19=Portf!Z22*Portf!R22
U20U20=Portf!X23*Portf!R23
U41:X41U41=LET(f,FILTER(E18:AA33,(V18:V33>=U38)*(V18:V33<=V38)),IF(ISERR(ROWS(f)),"Ingen utbytte",SORT(INDEX(f,SEQUENCE(ROWS(f)),{1,17,18,20}),4)))
AB41:AE41AB41=LET(f,FILTER(E18:AH33,(AC18:AC33>=AB38)*(AC18:AC33<=AC38)),IF(ISERR(ROWS(f)),"Ingen utbytte",SORT(INDEX(f,SEQUENCE(ROWS(f)),{1,24,25,27}),4)))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L18:L33,S18:S33,Z18:Z33,AG18:AG33,AN18:AN33,AU18:AU33,BB18:BB33,BI18:BI33,BP18:BP33,BW18:BW33,CD18:CD33,CK18:CK33Cell Value>0textNO
Cells with Data Validation
CellAllowCriteria
AB38:AC38List=#REF!#
U38:V38List=#REF!#


So, the problem occurs if I delete the row Y or Z for example. I need help to fill in at the end under INDEX so this formula is adapting no matter how many cells are in between.
 
Upvote 0
but, say you have a range of A1:Z50... and you know you want to start in cell A5 and go to the first cell that has a value of 100 in it (assume there is no 100 in cells A1:A5:
the calculation to create that range is: A5:INDEX(A1:A50,Match(100,A1:A50,0) (In this simple example you could even say Match(100,A5:A50,0) in the middle of the index statement.
I am returning 4 different columns with this 1 formula and those 4 columns are specified at the very end. How can I make the INDEX return the same formulas based upon your example with Col B that only returns 1 column?
 
Upvote 0
Your spreadsheet confuses me. It looks like your have repeating information of 6 rows and 7 columns.
If that is correct, what is it you need to do with thos 6x7 grids? When you mention formula, do you mean your big LET formula? Also, your formulas reference cells on sheet Portf, some sample frm that could help, too.
 
Upvote 0
Your spreadsheet confuses me. It looks like your have repeating information of 6 rows and 7 columns.
If that is correct, what is it you need to do with thos 6x7 grids? When you mention formula, do you mean your big LET formula? Also, your formulas reference cells on sheet Portf, some sample frm that could help, too.
Testark 02.02.23.xlsx
ABCDEFGHIJKLMNOPQRSTUVWX
1en1016.01.202314.12.20231619.01.2023
2to2201.03.202314.02.202302.03.2023
3
4
5tre2312.03.202317.02.2023
6fire4015.02.202312.01.202329.10.202316.02.2023
7fem1103.01.202316.12.20231704.01.2023
8seks2418.03.202303.03.202318.03.202321.03.2023
9sju2525.03.202311.03.2023
10åtte2631.03.202321.03.202303.03.202304.04.2023
11ni1213.01.202329.12.20231816.01.2023
12ti2710.03.202315.02.202327.01.202325.01.2023
13elleve1325.01.202304.01.202312.12.20231926.01.2023
14tolv1413.01.202329.12.20232016.01.2023
15tretten2825.03.202324.02.202328.03.2023
16fjorten1503.01.202313.12.202311.11.20232104.01.2023
17femten5014.02.202301.02.202325.01.202323.01.2023
18seksten2911.03.202314.02.202314.03.2023
19sytten
20atten3022.03.202307.03.202324.02.202323.03.2023
21nitten3111.03.202317.02.2023
22
23
24
25
26
27
28
29
30
31
32
33
34
3501.01.2023
3631.12.2023
37
38
39
40
41to2201.03.202314.02.2023
42seksten2911.03.202314.02.2023
43ti2710.03.202315.02.2023
44tre2312.03.202317.02.2023
45nitten3111.03.202317.02.2023
46tretten2825.03.202324.02.2023
47seks2418.03.202303.03.2023
48atten3022.03.202307.03.2023
49sju2525.03.202311.03.2023
50åtte2631.03.202321.03.2023
51
52
53
Ark1
Cell Formulas
RangeFormula
Q41:T50Q41=LET(f,FILTER(A1:W33,(R1:R33>=Q35)*(R1:R33<=Q36)),IF(ISERR(ROWS(f)),"Ingen utbytte",SORT(INDEX(f,SEQUENCE(ROWS(f)),{1,17,18,20}),4)))
Dynamic array formulas.


I have updated the spreadsheet now, maybe easier to see how the formula is working.

Now, for example, If I remove the column 'O', the formula changes and is not displaying what it should because the columns are hard coded in the very end of the formula.

Can you try to find a solution for not hard coding/taping in the columns at the end?
 
Upvote 0

Forum statistics

Threads
1,215,545
Messages
6,125,448
Members
449,227
Latest member
Gina V

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