Excel reference a range based on a string - excel

I would like to input a number in a range from another sheet and I don't know how to do it.
The function:
=PERCENTRANK.INC(sheet1!$C$6:$C$**96**;sheet1!$C$6))
For example: The result of this function should be in a range of 10 days. So the range would be sheet1!M6:M16 (not sheet1!M6:M96)
I want input different numbers on the "96" space.
And I have a large matrix so it's impossible to do it manually.
Thank you so much!!

Avoid the use of volatile INDIRECT and OFFSET set-ups when a perfectly good non-volatile INDEX set-up is available.
=PERCENTRANK.INC(Sheet1!C6:INDEX(Sheet1!C:C,G3),Sheet1!C6)

=Average(indirect("sheet1!M6:M"&A1)) in A1 put 96

You may want to replace the range inside the average: =AVERAGE(FILTER(…)) where you can define a range by certain criteria.
edit:
If you want to use the absolute cell reference, see the answer from Zorigt.
Alternatively, you could also use the OFFSET function to define your range starting from a reference cell (e.g. 10 rows for 10 days)
With the filter you could define e.g. from which day to which day and/or any other criteria

If you want dynamic range as per the input you will give better make use of the address function with indirect. indirect takes static cell reference.
=ADDRESS($C$3+6,3)
Result: $C$16
=PERCENTRANK.INC($C$6:INDIRECT(ADDRESS($C$3+6,3)),C6)
however this function doesn't ignore the values outside the range that you gave.
so to overcome this problem you can check if the range you gave and the current row/cell in the formula is greated then or equal.
=IF(ROW(INDIRECT($D$3))>=ROW(),PERCENTRANK.INC($C$6:INDIRECT($D$3),C6))

Related

Automate concatenation process

Here I am stucked with one excel issue where i want to concatenate from column F till column I where the logic is when the benchmark column A3 (for example) is blank it need to concatenate column F till column I till there is a value at column A4.and this logic need to automatically concatenate the mentioned column till there is a value under the benchmark column. currently i need to keep change the concatenate range in order to concatenate it fully with the logic. Appreciate if anyone can help me out.
Below image shows how i am doing manually which very time consuming
You can use the MATCH function (with a wildcard) to find the next non-blank row; and use that in an INDEX function to detect the range to concatenate.
Assuming your data starts in A3 and the lowest possible row is row 1000 (change the 1000's in the formula below if it might be much different:
J2: =IF(A2="","",CONCAT(INDEX(F2:$I$1000,1,0):INDEX(F2:$I$1000,IFERROR(MATCH("*",A3:$A$1000,0),1000-ROW()),0)))
Note: It is possible to also develop solutions using INDIRECT and/or OFFSET. Unfortunately, these functions are volatile, which means they recalculate anytime anything changes on your worksheet. If there are a number of formulas using these functions, worksheet performance will be impaired. INDEX and MATCH are non-volatile (except in ancient versions of Excel - pre-2003 or so)
The OFFSET-function would come on handy here. One solution is to do it like
This works in my worksheet.
Cell Q6 just defines the number of rows downwards that the MATCH-function is checking for the next "HEADER1" value. If "HEADER1" is found, the MATCH-function returns how many rows down-1. If no "HEADER1"-value is found within that range, that value is then the number of rows used.
If the first column also has "HEADER2" and so on, you can add the MID-function to both references inside MATCH to limit which part of the string are to be searched for.
I tried to adjust the references properly to fit your sheet, but I may have missed something:
=IF(ISBLANK($B2),"",CONCAT(OFFSET($B2,0,0,IFNA(MATCH(MID($B2,1,6),MID(OFFSET($B2,1,0,$B$1),1,6),0),$B$1),4)))

How can I make my function reference all the cells in my column that are being used instead of just having a broad function?

I have many formulas that reference a large list and at the time I just have them to 1000 to make it easy. There will come a day that I will surpass 1000 and I don't want to have to continuously update the function but at the same time I don't want to have an excessive range.
The following function is in cell CM4 and I have data in cells CM11:CM52 and each day one more gets added at the bottom. What kind of function could I use to just take the average of CM11:CM52 that will reference CM11:CM53 tomorrow and so on and so on?
The following formula is a simple one that is in my worksheet:
=AVERAGE(CM11:CM1000)
Many formulas do not have a cost to using full column references. AVERAGE() is one of them so there is no problem using
=AVERAGE(A:A)
Or if you want to start on a certain row:
=AVERAGE(CM11:CM1048576)
For those formulas that do matter ie Array Types then we can make it dynamic with INDEX/MATCH
=AVERAGE(CM11:INDEX(CM:CM,MATCH(1E+99,CM:CM))
If the column in question is text then use "zzz" instead of 1E+99
I would suggest adding your data to a table (insert>table). This will allow the formulas to update automatically.

ADDRESS TO RANGE

I have this formula:
=MATCH(""&"W"&C2&"",'Raw Data'!$5:$5,0) --> Which extract the column number, then
=SUBSTITUTE(ADDRESS(1,E3,4),"1","") --> I convert to letter
It returns: DH
Finally, I want to use that value of "DH" into the following formula
=INDEX('Raw Data'!A:A,MATCH(E26,'Raw Data'!DH:DH,0))
I tried many times and ways without success.
Data is dynamic, so the first value I'm looking for W2 (for example) will not always be in the same column.
Depending on the variable which you get on the column number, I want the spreadsheet to select that column.
Here is a simplified demonstration of what I think you are trying to do here:
Formula in A3:
=INDEX(A11:A20,MATCH(A2,INDEX(A11:E20,,MATCH("W"&A1,5:5,0)),0))
As you see, this can be done without transformation of a column number into a letter reference. It's simply a matter of nested INDEX/MATCH functions as per #BigBen in the comments.
Please adapt the above to suit your ranges.
Few more remarks just for future reference:
ADDRESS - This is a so-called volatile function. Though maybe not obvious these type of functions recalculate on any save, open, edit on your worksheet. The more of these, the slower your workbook gets.
""&"W"&C2&"" - There is no need to concatenate empty strings in front of other string values leaving you with the exact same results but formulas that are simply harder to read.

Excel: COUNTIF + OFFSET in another worksheet

Not sure why this wouldn't work:
COUNTIF(OFFSET(OtherSheet!F5,0,0,4,1),"<10")
Trying to count values less than 10 in 4 rows of another worksheet. Of course, I can use OtherSheet!F5:F8 instead of the OFFSET like so:
COUNTIF(OtherSheet!F5:F8,"<10")
and this works fine. but I'm trying to work up to where the "4" is dynamically determined. But, I can't even seem to get the OFFSET to work correctly when the range is in another spreadsheet.
Thanks!
Derek
Don't know about OFFSET, but it is volatile and I avoid it whenever possible. I would use INDEX, which is not volatile:
=COUNTIF(Sheet1!$F$5:INDEX(Sheet1!$F$5:$F1040000,4),"<10")
Replace the 4 with the cell in which you want to place the size of the array.

Using CountIf in excel with row() as the 2nd range

Is it possible to have a function in Excel where the second range is the current row the user is current at? For example, if column A has customer numbers then can a user have column B be the current count of rows that have the same customer number? Something like =countif(A1:Row(), Row()). So, if the user were on B14 then the function would be =countif(A1:A14, A14).
I'd rather not use VBA and I'm new to functions in Excel. My apologies if it's a simple answer. I swear that I did search for an answer before firing off this question.
The answer to your question is yes. Use INDIRECT function. Something like:
=COUNTIF(INDIRECT("A1:A"&Row()), INDIRECT("A"&Row()))
You could use something else rather than taking the current row you could have a drop-down list with all the ids. The cell remains the same but you will be able to select the number that you want from the list and use it to count.
Have a look here and tell me if you need more help:
http://www.techrepublic.com/blog/microsoft-office/how-to-add-a-drop-down-list-to-an-excel-cell/
Another approach:
=COUNTIF(OFFSET($A$1,0,0,ROW()),A:A)
Better than using the "fully" volatile OFFSET and INDIRECT set-ups is to use one with INDEX, which, in this construction, is merely volatile "at workbook open".
Also, if you are looking for a formula which can be copied to other cells such that the row referenced is always that in which the formula resides, it is much better to use a construction with ROWS rather than ROW, since the latter is affected by row insertions within the range whereas the former is not. Hence, the formula placed in row 14 would be:
=COUNTIF(A1:INDEX(A:A,ROWS($1:14)),INDEX(A:A,ROWS($1:14)))
Regards

Resources