how to have existing formula change by entering numbers into two separate cells

drooperman

New Member
Joined
Feb 26, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I was wondering if someone could please help me. I have a sheet with numbers data that I am calculating through various formulas such as sums and ranges and averages and sort functions etc. My problem at the moment is that I have for instance in Column Y a set of numbers that is the main Numbers references that I entered in manually such as 1 to 10 or 4 to 19 or 19 to 29 etc. this list varies on different sheets and will never change after I have entered them the first time, as they are the main numbers. then I have the data in column Z that will change as I enter new figures into the chosen cells on other sheets. lets say for instance on sheet one these main numbers in column Y are 1 to 10. Next to each of these 1 to 10 numbers in column Z is the results of my sorting or range or xlookup formulas that I have asked for that is delivered to me. Now out of this data in column Z (next to the numbers 1 to 10), I currently have a sort formula that sorts this data into top 3 numbers for me. this sort formula is looking throughout all the 1 to 10 numbers and their accompanying data in column Z to find the top 3 numbers and then shows me the top three numbers out of 1 to 10 with its accompanying data next to it. [=SORT(FILTER(V197:W205,W197:W205>=LARGE(W197:W205, 5)), 2, -1)] The Problem I face is that sometimes this sort formula gotta be between main numbers 2 and 8 or 1 and 7 or between 3 and 9, it doesn't stay always just 1 to 10, which then requires me to manually edit the formula every time which is a lengthy process since there are over 40 columns of such data. Is there a way that I can make this formula work by me entering the start number (2) and end number (8) into two different cells which will tell this Sort formula where to start and end the top 3 numbers search? thanks in advance for all your efforts. :)
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi Peter,

sory for bothering you again, could you maybe assist with doing the same to these three formulas. Rank/Average & XLookup.

Your help is much appreciated. thanks.
 

Attachments

  • Screenshot (88).png
    Screenshot (88).png
    78.3 KB · Views: 8
  • Screenshot (89).png
    Screenshot (89).png
    80.3 KB · Views: 8
  • Screenshot (90).png
    Screenshot (90).png
    81.7 KB · Views: 8
Upvote 0
Could we get the samples with XL2BB now?
sory peter I looked at a few videos on how to do the Xl2bb

TEST EXAMPLE 1.xlsx
RSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBN
1RANK:
2378
3382
4396
5407
6415
7424
8433
9449
104510
11461
125.5
13
14
15AVERAGE:
16
17
18
19ENTER FROM RANGE & TO RANGE:
20From:To:
213745
22
23Top Results:
245
25
26373
27389
28395
29404
30416
31427
32438
33442
34451
354610
36
37
38389Currently this gives me top 3 of ALL THESE 10
39438
40427
41416
42395
43IF I want to get the top 3 of only NUMBERS 2 to 8 then I have to manually go in and change that formula to look only in 2 to 8.
44 Is there a way that I can just enter the FROM number in the top box to be 2 and the TO number to be 8 and then get the results
45 instead of having to keep changing the formula?
46
47
48370
49389
50395
51400Xlookup Numbers
52416
53427
54438
55440
56450
57460
58
Example
Cell Formulas
RangeFormula
Y3:Y11,Y49:Y57,Y27:Y35Y3=Y2+1
Z2:Z11Z2=RANK.EQ(Z26,Z$26:Z$35)+COUNTIF(Z26,Z26)-1
Z12Z12=AVERAGE(Z2:Z11)
Y38:Z42Y38=INDEX(SORT(FILTER(Y26:Z35,(Y26:Y35>=W21)*(Y26:Y35<=AA21),""),2,-1),SEQUENCE(W24),{1,2})
Z48:Z57Z48=XLOOKUP(Y48,Y$38:Y$42,Z$38:Z$42,0)
Dynamic array formulas.



Hope this helps
 
Upvote 0
Could we get the samples with XL2BB now?
RANK:
378
382
396
407
415
424
433
449
4510
461
5.5AVERAGE:
ENTER FROM RANGE & TO RANGE:
From:To:
3745
Top Results:
5
373This is my data Set
389
395
404
416
427
438
442
451
4610
389Currently this gives me top 3 of ALL THESE 10
438
427
416
395
370Xlookup Numbers
389
395
400
416
427
438
440
450
460


To be clear, I want both the top Rank section, the average section below it and at the bottom the x lookup section all to change with the SORT section when I edit the FROM and TO numbers.. is this possible?
 
Upvote 0
I'm not sure what the expected results are or exactly how they would be displayed.

Can you create an example where From = 41, To = 45, Top results = 4 and manually enter all the results where you would want them & post that.
Best also to get rid of all that text description about top 3 when your example is no longer about that.
 
Upvote 0
Hi Peter thanks. see this sheet is as the numbers should appear as it should be on 41 and 45 figures

See if this helps..

TEST EXAMPLE 1.xlsx
STUVWXYZAAABACADAEAFAG
1RANK:
2378
3382
4396
5407
6413
7422
8431
9444
10455
11461
123AVERAGE:
13
14
15
16
17
18
19ENTER FROM RANGE & TO RANGE:
20From:To:
214145
22
23Top Results:
244
25
26373
27389
28395
29404
30416
31427
32438
33442
34451
354610
36
37
38438
39427
40416
41442
42
43
44
45
46
47
48370Xlookup Numbers
49380
50390
51400
52416
53427
54438
55442
56451
57460
58
Example
Cell Formulas
RangeFormula
Y3:Y11,Y49:Y57,Y27:Y35Y3=Y2+1
Z2:Z5,Z11Z2=RANK.EQ(Z26,Z$26:Z$35)+COUNTIF(Z26,Z26)-1
Z6:Z10Z6=RANK.EQ(Z30,Z$30:Z$34)+COUNTIF(Z30,Z30)-1
Z12Z12=AVERAGE(Z6:Z10)
Y38:Z41Y38=INDEX(SORT(FILTER(Y26:Z35,(Y26:Y35>=W21)*(Y26:Y35<=AA21),""),2,-1),SEQUENCE(W24),{1,2})
Z48:Z57Z48=XLOOKUP(Y48,Y$30:Y$34,Z$30:Z$34,0)
Dynamic array formulas.
 
Upvote 0
Can you create an example where From = 41, To = 45, Top results = 4 and manually enter all the results where you would want them & post that.
If that is what you have now provided, then ..

In relation to RANK you already have formulas and they seem to have nothing to do with 41, 45 or 4 so if those are the results you want you are already all set.

In relation to the XLOOKUP section I have provided formulas in column Z that replicate the values in your post above and should adjust if the 41 or 45 change. Those results seemed to have nothing the do with "top 4"?
I have also provided a dynamic array formula in AB$8 that possibly may be of use.

drooperman.xlsm
WXYZAAABAC
20From:To:
214145
22
23Top Results:
244
25
26373
27389
28395
29404
30416
31427
32438
33442
34451
354610
36
37
38438
39427
40416
41442
42
43
44
45
46
47
48370416
49380427
50390438
51400442
52416451
53427
54438
55442
56451
57460
Sheet2
Cell Formulas
RangeFormula
Y27:Y35,Y49:Y57Y27=Y26+1
Y38:Z41Y38=INDEX(SORT(FILTER(Y26:Z35,(Y26:Y35>=W21)*(Y26:Y35<=AA21),""),2,-1),SEQUENCE(W24),{1,2})
Z48:Z57Z48=IF(OR(Y48<W$21,Y48>AA$21),0,XLOOKUP(Y48,Y$26:Y$35,Z$26:Z$35,0))
AB48:AC52AB48=FILTER(Y26:Z35,(Y26:Y35>=W21)*(Y26:Y35<=AA21),"")
Dynamic array formulas.
 
Upvote 0
Solution
If that is what you have now provided, then ..

In relation to RANK you already have formulas and they seem to have nothing to do with 41, 45 or 4 so if those are the results you want you are already all set.

In relation to the XLOOKUP section I have provided formulas in column Z that replicate the values in your post above and should adjust if the 41 or 45 change. Those results seemed to have nothing the do with "top 4"?
I have also provided a dynamic array formula in AB$8 that possibly may be of use.

Hi Peter,

Thank you first and foremost for all your effort. Greatly reduced my effort that I need to manage this sheet.

The sort Solution worked great. The Xlookup set: I tried the first filter solution you provided but I needed something that kept the data in order so that
I can use the Sort solution you provided on some sheets on this specific data results, so hence why I really appreciate your dynamic array formula in AB$8.
That was exactly what I was looking for. Something that will keep the data set as it is.. this must be the same for my Rank Data

With regards to the average result underneath my Rank Data Set (Z12) I found the following solution =AVERAGEIFS(Z2:Z11,Y2:Y11,">" &AI12,Y2:Y11,"<" &AM12) but for some
reason I have to have a separate "FROM & TO" box (AI12 & AM12) that deduct 1 digit from my MAIN "FROM & ADDS 1 digit to the TO" to get the correct Average Result. I tested the
result by just using the same range on a seperate =Average formula and it wont work unless I deduct 1 digit from the "FROM" number and ADD one Digit on the "TO"
number?? just thought to share that with you and for incase someone else have the same problem in the future. If you can improve on this great otherwise it does what
I need so I am not much concerned over the Average Data Calculation Result.

As for the Rank. I still Need the Rank though. To clarify.. I want the rank to only Rank the range of whatever we enter INTO the "FROM & TO" boxes. At the moment
it ranks everything from 37 to 46. But ideally when I enter 41 and 45 I don't want it to rank 41 to 45 against all the other numbers as well. I only want 41 to 45 ranked with the rest of the
numbers ie: 37, 38, 39, 40 and 46 showing ZERO (0)
See below in Ranked Section.

Ive updated the sheet with all your previous suggestions. Its just Rank that I am trying to get as well..

TEST EXAMPLE 1.xlsx
PQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS
1
2RANK OF DATA SET370
3380
4390
5400
6413
7422
8431
9444
10455 Average FROM & TO ARRAY RANGE (DO NOT EDIT)
11460From:To:
123.003AVERAGE:4046
13
14
15
16
17
18
19ENTER FROM RANGE & TO RANGE:
20From:To:
214145
22
23Top Results:
244
25
26DATA SET:373
27389
28395
29404
30416
31427
32438
33442
34451
354610
36
37
38DATA SET SORT438
39427
40416
41442
42
43
44
45
46
47
48DATA SET LOOKUP370
49380
50390
51400
52416
53427
54438
55442
56451
57460
58
Example
Cell Formulas
RangeFormula
Z6:Z10Z6=RANK.EQ(Z30,Z$30:Z$34)+COUNTIF(Z30,Z30)-1
Y3:Y11,Y27:Y35Y3=Y2+1
Y12Y12=AVERAGE(Z6:Z10)
Z12Z12=AVERAGEIFS(Z2:Z11,Y2:Y11,">" &AI12,Y2:Y11,"<" &AM12)
AI12AI12=W21-1
AM12AM12=AA21+1
Y38:Z41Y38=INDEX(SORT(FILTER(Y26:Z35,(Y26:Y35>=W21)*(Y26:Y35<=AA21),""),2,-1),SEQUENCE(W24),{1,2})
Y48:Y57Y48=Y26
Z48:Z57Z48=IF(OR(Y48<W$21,Y48>AA$21),0,XLOOKUP(Y48,Y$26:Y$35,Z$26:Z$35,0))
Dynamic array formulas.
 
Upvote 0
That example looks a little more like what I was expecting.
However, why do you have 45 ranked in the top section when it does not meet the "top 4 results" restriction?
If you do want that ranked, why does it get ranked 5? And what if there was more than one value not included in the "top n results"? How would you rank multiples of those?

BTW, you don't need those separate From/To values, you just need to use >= and <=

Excel Formula:
=AVERAGEIFS(Z2:Z11,Y2:Y11,">=" &W21,Y2:Y11,"<=" &AA21)
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

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