Today I have a problem with my excel spreadsheet. I am getting cells displaying #REF! error on the result cell! I checked the formula and there is nothing with it at all.I need to select a calculation from text box and a value from a second text box to give me a value from a table based on my formula! My formula is as follows:
=IF(F55="Select Size","",VLOOKUP(F55,INDRECT(CONCATENATE($F$51,"s")),3,FALSE))
Any help would be much appreciated!
The second parameter in VLOOKUP is a table_array, i.e. a 2-dimensional area in in your spreadsheet defined by the top left corner and bottom right corner, so in your spreadsheet it could be something like $G$1:$I$10.
So for your formula to work using INDIRECT and CONCATENATE, $F$51 would have to contain the first part of a range e.g. the text "$G$1". Then you would need to concatenate this with the second part of the range e.g. ":$I$10" to get a valid range like "$G$1:$I10" as a string which INDIRECT would return as a valid reference like $G$1:$I$10.
But in the formula that you've currently got, whatever is in $F$51 is concatenated with the character "s". I don't know what's in $F$51, but it could only return a valid reference if it's something like "Q:" and you're specifying three whole columns - anything else would give a "#REF!" error.
To see what's happening, go to Formulas | Evaluate Formula.
Related
I would like to highlight a cell which is the closest the a specific value but still lower (below) or equal according to a formula.
For instance, if I have 14 in B4, I would like the cell 13 (or 14) highlighted but not 15 in the range.
The value I need to look for would be in B4 and the range that I must apply the highlight formula to would be L1:L371.
So far, the best result I was able to achieve was with (from what I was able to find using Google or Stackoverflow already existing content):
=SMALL($L1:$L317,COUNTIF($L1:$L371,"<="&$B$4))
Although, not only it selects the value I am looking for, it also selects all the values below.
May someone provide me some help so I can achieve the expected result please?
Thank you for your time and help, it is greatly appreciated.
Based on your description, it seems like you need to find the maximum value of a range (L1:L137) that is less than or equal to an input variable (B4) and highlight that value in the search range. Depending on what version of Excel you have, here's what you need to do:
For Excel 2019 or Excel 365
You can use the MAXIFS function. You would actually put that function in a conditional formatting rule, but more on that in just a second. As a test, put the following code in cell B5:
=MAXIFS($L$1:$L$137,$L$1:$L$137,"<="&$B$4)
The first argument is your "MAX_RANGE", or the range that contains the values you want to find the max of. It is also our "CRITERIA_RANGE", the second argument. The third argument is the criteria itself, which is that the search range must be less than or equal to the value in cell B4. Essentially, we are going through the list and creating a subset of numbers that are less than or equal to our search value, and discarding the rest. I assume you are aware of relative vs. absolute referencing, since you used the "$" anchor in your referenced code. If not, here's a description of the difference.
Now, the result of that formula should be the highest number in the list less than or equal to the search value, but that doesn't highlight it for us in our list. To do this we need conditional formatting. To do this, highlight your data range (L1:L137) and go to the conditional formatting drop down on the home tab of the menu ribbon. Choose "New Rule". On the dialog that pops up, choose, "Use a formula to determine which cells to format". In the formula input box, enter:
=L1=MAXIFS($L$1:$L$137,$L$1:$L$137,"<="&$B$4)
This will compare whether the value in the cell being evaluated (L1, for instance) is equal to the result of that formula we talked about above. Since L1 is only relatively referenced, this formula will work for every cell in the data range.
Now, before you hit "OK" on the dialog, select the Format button. This will allow you to adjust your highlighting and formatting as you desire. Click "OK" on the formatting dialog, then "OK" on the Conditional Formatting Rule dialog. This should now highlight any data cell that is equal specifically to the result of our formula, and not everything that's less than our value.
For Earlier Versions of Excel
The concept is the same in earlier versions of Excel, but unfortunately, the MAXIFS function is not present in these versions. Instead, we must use an array formula. Array formulas are a whole other can of worms, but ExcelJet is an excellent resource. In fact, they talk about this very issue, here.
Unfortunately, we can't put the array formula in the conditional formatting formula like we did above, so we'll need to put this formula on a cell in the worksheet, then the conditional formula should reference that new cell. So in cell B5, if you put:
=MAX(IF(L1:L137=B4,L1:L137)
And then, instead of pressing Enter, you must press Ctl + Shift + Enter
This keyboard combination will tell Excel that you are trying to enter an array formula. If you don't press these keys, then the formula will error. Once you have entered the array formula, if you put your cursor in cell B5, you will see the formula bar at the top has added curly braces ({ , }) around the formula to look like
{=MAX(IF(L1:L137=B4,L1:L137)}
This leads to the same result as above, but is just achieved slightly differently. Now, following the same process described above for conditional formatting, you will simply set the formula to:
=L1=$B$5
And that should be it! Hope this helps!
In order to do some calculations on averages and differences of values in columns, I've defined a name, based on a range, but it seems to be completely going berserk:
I have a cell (D13), defined as Header_First _Answer, which contains the title of the column, and I have a value (currently being 69), which contains the number of entries, called Total_Count.
I've defined the entries of that column as another name: "All_First_Answered_Dates", defined as =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0) (start by the first entry under Header_First_Answer, take up to 69 entries, and define a range out of this).
In cell G5, I'm using that name in order to do some calculations (calculating averages), but this seems not to work (there is a #Value error).
After second comment from Rory: G5 formula and first formula evaluation result:
Formula:
=AVERAGE(IF(ISBLANK(All_First_Answered_Dates);TODAY();All_First_Answered_Dates) - All_Start_Dates)
First evaluation result:
=AVERAGE(IF(ISBLANK(#Value!);TODAY();All_First_Answered_Dates) - All_Start_Dates)
Hence, my conclusion:
After some checking I've found out that this is due to the name "All_First_Answered_Dates", which seems to be interpreted one time too many (or how do I explain this):
In different cells, I've entered the formula =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0) (which is exactly the meaning of "All_First_Answered_Dates"), and every time, using the Evaluate Formula feature, I see that the last but one result is correct: $D$14:$D$82. However, after that, another evaluation is done, turning this value into 43283 (in case the formula is entered in "J14"), 43300 (in case the formula is entered in "J15"), ..., and in case I enter this formula in a cell with row number lower than 14, I have the error value #Value (which explains the wrong result in cell G5).
If I simply put the formula =$D$14:$D$82 in any of the mentioned cells, then the content of some cells in column D are shown (which are dates, not values like 43283 or 43300).
It appears that declaring a range as =x:y, where x and y are formula results, is not working.
Does anybody know how I can define a range as a formula, which I can then use in order to define in a name?
I can imagine my explanation being quite complicated without an image, hence the attached screenshot. In there:
In cell J13, there is the formula =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0).
In cell J14, there is the same formula.
In cell K14, there is the formula =$D$14:$D$82.
For completion purposes, hereby a screenshot of the name manager, containing both mentioned names (the ones, selected in the name manager):
Edit after first comment:
The idea behind the range is the following:
1. Take the first row under Header_First_Answer, do not take any other column : OFFSET(Header_First_Answer;1;0)
2. Take the Total_Count's row under Header_First_Answer, do not take any other column : OFFSET(Header_First_Answer;Total_Count;0)
3. Define a range, based on those two cells, by putting a semicolon between them.
I was not aware of the height and width features of the Offset() worksheet function. I've implemented them, which makes the formulas much easier.
Unfortunately the problem still persists.
Thanks in advance
Dominique
I've just found the answer of what was going wrong:
The formula was meant to be an array formula. Something went wrong and while trying to debug, I accidently re-formatted the formula into a normal formula (I must have pressed "ENTER" instead of "Ctrl" + "Shift" + "ENTER") at some point.
I have re-applied array formula (using "Ctrl" + "Shift" + "ENTER"), getting a formula like:
{=AVERAGE(IF(ISBLANK(All_First_Answered_Dates);TODAY();All_First_Answered_Dates) - All_Start_Dates)}
(mind the braces {, })
Now everything is working fine.
I am trying to use the result of a TRANSFORM inside an IF statement where if the value returned in transform is blank, the value_if_true should look up the value of the previous cell, add one to it and show that, otherwise just show the result of the transform.
My issue is that the formula inside value_if_true, returns #VALUE even though on evaluation it is calculating the right value to return but if I replace it with a static text it works fine.
Below is what I'm trying to do:
{=IF(TRANSPOSE(Master!A7:A110)="",INDIRECT("RC[-1]",0)+1,TRANSPOSE(Master!A7:A110))}
This is what works:
{=IF(TRANSPOSE(Master!A7:A110)="","blah",TRANSPOSE(Master!A7:A110))}
Thank You!
Are you sure the value in RC[-1] is a number? If it is text and can't be converted to a number, then it will return #Value
Also, are you entering this array formula into a single cell and then filling it, or are you array-entering it into an entire range at once? If you're array-entering it into the entire range at once, then also be aware that RC[-1] will always refer to the cell that is to the left of the top-left cell of the output-array range.
Sorry for responding so late, surprisingly using named ranges instead of explicitly calling them out has solved the problem. To explain:
This is my data in the 'Reference' sheet. It is merely week numbers expressed in descending YYYYWW format:
201701
201702
201703
201704
201705
201706
201707
201708
The size of this list changes as data for more weeks flows in, the maximum items it can have is 104 weeks (two years rolling data). I've selected the entire 104 row range say $A$1:$A$104 that this list can expand to occupy and named it ListOfWeeks
On my display sheet I have selected the full 104 column range that these dates will be transposed into say $I$6:$DH$6 then entered the following formula into the formula bar:
=IF(TRANSPOSE(ListOfWeeks)=0,"",TRANSPOSE(ListOfWeeks))
followed by a Ctrl+Shift+Enter and it is working just fine.
I used this VLookup formula to retrieve value from another sheet Sheet2 which contains a table with two columns NumEchelon, Indice:
=RECHERCHEV("1/1";Sheet2[NumEchelon];Sheet2[Indice];faux)
But it doesn't return any value, when i click on the cell i found just the formula not the value i want to retrieve from the sheet Sheet2.
Looks like you are using french version of Excel, so I will leave it up to you to find the translated commands. The basic problem from what I am gathering is you are looking up "1/1" in the named range NumEchelon. I am going to guess that this named range is 1 column wide. sheet2[Indice] is a separate chunk of data.
Vloopkup is supposed to search for a specified term in a table (usually 2 or more columns wide located to the right of the search column) and return a value in the same row as the found value in a specified column. The columns are numbered left to right with the first column being zero. The false or FAUX at the end tells it you want an exact match.
So without seeing your data I would say make sure that NumEchelon covers both columns of information, and INDICE column is to the right of NumEchelon. Where you have Sheet2 Indice replace with with a numeric value for the column its from the table you made for the vlookup.
So Assuming NumEchelon is A1:A8 and Indice is B1:B8 I would do the following:
Use a new named range "MonTableaux" and define it as sheet2!A1:B8
=VLOOKUP("1/1",MonTableaux,2,0)
Without the named range it would look like
=VLOOKUP("1/1",sheet2!$A$1:$B$8,2,0)
'note the 0 is the same as false
Now you may be using TABLES and I am not all that familiar with table so there may be short cuts. If that is the case someone point it out to me and I will delete my answer.
If your information you want to return in not lined up vertically with the information you are searching for or if the information you want to return is located to the left of what you are searching for you will want to use a combination of INDEX and MATCH. maybe something like this:
=INDEX(sheet2[Indice],match("1/1",sheet2[NumEchelon],0))
If the formula is showing up in the cell, and not a result like #N/A then the cell is likely formatted as Text, change it to General and click in the formula bar and hit enter again to show the formula result instead of the formula text.
This links to question 12299700 - I want to understand why SEARCH returns #Value when used alone but works when embedded into LOOKUP, and how I can make it work alone:
In Cell A1 I have a string of text: "This is some sample text"
In Cells D1:D4 I have words: "text, sample1, sample2, string" (all in separate cells)
I want to see if my string contains any of the words in my range - I don't need the matching word/s returned.
Using the Search function in any empty cell in Row 1 =SEARCH($D$1:$D$4,A1), returns 22. Good!
Using this in any other row returns #VALUE. Why?
If I keep my formula in Row 1, but move my range of words down to D2:D5, I get #Value. Why?
How can I make SEARCH work for my cell and ranges, in any cell?
(From the answer to question 12299700 I know I can use this formula to return the matched text, in any cell of the spreadsheet: =LOOKUP(2^15,SEARCH($D$1:$D$4,A1),$D$1:$D$4) - this includes a term that gives #VALUE on its own ... intriguing).
First question asked on Stackoverflow - feedback appreciated.
The function SEARCH returns #VALUE if the searched string was not found within the text. The function SEARCH expect only one searched string. It is not a array function itself. So if it gets a range as searched string, it uses only one of these range values as searched string. Which one it is, depends on the position of the formula.
Within LOOKUP the case is completely different. LOOKUP is an array formula itself. It gets the SEARCH($D$1:$D$4,$A$1) as { SEARCH($D$1,$A$1), SEARCH($D$2,$A$1), SEARCH($D$3,$A$1), SEARCH($D$4,$A$1) } which results in a array like { #VALUE, 21, #VALUE, 21 } depending of if SEARCH finds the string or not. That LOOKUP even works with such an array is strange. Normally it needs a sorted array. But it works and gets the last value which is lower or equal than the searched value.
If you need to use SEARCH like an array formula outside a native array formula, then you have to create this array context by entering the formula with [CTRL]+[SHIFT]+[ENTER] instead of only [ENTER]. The formula gets then curly braces around it.
In my example I have created such a formula in Cell E10.
If you are interested in how formulas work, you should often click fx and look how the single parameters comes through. And you should often use Evaluate Formula on the Formulas tab, in the Formula Auditing group.
What happens is that SEARCH is being used in an array form and is outputting in a linear form (non-array).
So, what happens in row 1 is that you're actually doing:
=SEARCH($D$1,A1)
Because evaluating a linear formula with an array tends to take the value from the array in the same row/column depending on the situation. So that means the above is looking for text in A1 which can be found.
On the second row, you will get:
=SEARCH($D$2,A1)
Which means it is searching for sample1 from A1 and since it cannot be found, you get #VALUE!.
To evaluate an array formula as an array, you will have to use Ctrl+Shift+Enter instead of pushing Enter after typing in the formula. Now the problem is that the formula above will return the same thing if you use only 1 cell...
If you want to see if your string contains any of the words in your range (and it's not important to know what word was found), then you will have to use another function along with SEARCH, for example, SUM and ISNUMBER and evaluating it as an array formula:
=SUM(ISNUMBER(SEARCH($D$1:$D$4,A1)))
And if you get a number above 0, you know there's at least 1 word in the text. Maybe to make the output more explicit:
=IF(SUM(ISNUMBER(SEARCH($D$1:$D$4,A1)))>0, "Word(s) found!", "No words found...")
If you want to know what word was found, you will have to use it as a normal formula and drag it down:
The reason why it works in VLOOKUP is that this function actually expects an array as the second parameter and since SEARCH is returning an array, well, that works out just well.
Also, you can view how functions work by clicking on the cell with the function, then do to 'Formulas' in the menu bar and clicking on 'Evaluate formula':
From there you can see if something is being evaluated as a linear or array formula and see how cell references are being substituted with the actual values.