Bug in Vlookup Excel Function? - excel-formula

It seems to me that Excel (2016) might have a bug while using Vlookup.
it appears that the char "~" produces a fail in Vlookup, according yo the following:the range B1:B7 is defined as "T_Paths" and the formula in each cell in range C1 is VLOOKUP(B1,T_paths,1,False) etc. It works fine for all, except when char ~ appears in a cell

The solution is to use ~~ (meaning substitute one "~" for "~~") in he search term B1. This is due to the fact that ~ is taken as a wildchar (as * is).

Related

Excel noob needs help Replacing a mid value with a different value using excel formula

I'm new to StackOverflow and to Excel formulas!
I'm trying to replace the word "GIL64000" with the word "GIB64000", I need to do this across many cells A2: H6; A9: G13, etc.
The cells themselves contain information as follows: "GIL64000_XX_X" with "XX" varying between WH, BL,OR,PU, etc and the"_X" ranging from L, M, S, XL, XXL (shirt sizes).
So I have cells with values like: "GIL64000_OR_S" , "GIL64000_BL_XXL" , "GIL64000_MIN_M" , "GIL64000_MIN_L" etc.
I've tried to get the replace function working by doing this: =REPLACE("GIL64000";3;1; "B")
But it only does this within the cell I have the formula in.
I've tried to add A2: H6 to the formula, but it doesn't accept it and returns with #VALUE! error: =REPLACE(A2:H6;3;1;"B")
I tried some other string like "MID" function, but I can't figure out how to use MID with REPLACE: =REPLACE(MID(A2: H6;3;1; "B"))
I tried to follow some guides and I still can't seem to get it working.
In essence, what I Want is the word "GIL64000" with word "GIB64000" across all my cells and to be able to change the formula as I need it in the future for other values not only "GIL64000"
The REPLACE command only takes in one reference of the cell, and not a range.
Only Change which you need to make is =REPLACE(A2;3;1;"B"), and then just copy the formula (i.e. Ctrl + C, and Ctrl + V on the other cells where you want to change this).
Also, this cannot be applied on the cell itself but would be applied on an adjacent cell.
Let me know if this helps.
There is also the substitute() function which will work, have shown 2 variations - both will drag down, but the second allows customizing the characters to replace. You could put $ on the B3 and C3 for an absolute reference.
See:
Note: I did not just look for "B" although you could - it depends what other data is there...
I know you said you want a formula, but in this case, don't sneeze at the idea of using a CTRL+H. This looks like the perfect scenario for one.

Change part of excel formula with a constant value

I have an excel formula across a column for which the base changes every "x" number of rows. Note this "x" is not constant and keeps changing. e.g.
=D1/SUM(D$1:D$4)
=D2/SUM(D$1:D$4)
=D3/SUM(D$1:D$4)
=D4/SUM(D$1:D$4)
=D5/SUM(D$5:D$9)
=D6/SUM(D$5:D$9)
=D7/SUM(D$5:D$9)
=D8/SUM(D$5:D$9)
=D9/SUM(D$5:D$9)
I am trying to change the first part of the formulas without changing the second and vice versa. e.g. changing the numerator by 10 cells.
=D11/SUM(D$1:D$4)
=D12/SUM(D$1:D$4)
=D13/SUM(D$1:D$4)
=D14/SUM(D$1:D$4)
=D15/SUM(D$5:D$9)
=D16/SUM(D$5:D$9)
=D17/SUM(D$5:D$9)
=D18/SUM(D$5:D$9)
=D19/SUM(D$5:D$9)
or, changing the base by 100. e.g.
=D1/SUM(D$100:D$104)
=D2/SUM(D$100:D$104)
=D3/SUM(D$100:D$104)
=D4/SUM(D$100:D$104)
=D5/SUM(D$105:D$109)
=D6/SUM(D$105:D$109)
=D7/SUM(D$105:D$109)
=D8/SUM(D$105:D$109)
=D9/SUM(D$105:D$109)
Sometimes, both. Any guidance on how this can be possible?
Thank you.
the first part of this problem seems easy unless I am missing something?
Part 1:
Since the denominator is already in $x form, you can select and COPY the whole range of formulas and PASTE them 10 rows down and then CUT and paste it back into position. The COPY will update the numerators appropriately and when you CUT and PASTE it back into position they will now be just as you want? The second question will be a bit more of a challenge!
Part 2:
OK without VBA I can only think of a really long-winded way to change your demoninators, but I just checked that it does work:
To change the bottom.
Search and replace = with '=
Now you can edit the formulas more freely.
Search and replace D with D%
Search and replace D%$ with D
Search and replace D% with D$
get rid of the '= by using the Data>text to columns option
Now use the copy and paste, cut paste trick from part 1.
Then if you still need your $s back as they were you essentially repeat 1 to 5 again.
Sorry, this looks really long-winded, but if you are desperate and back up before you start it should work.
An excel formula can't replace another cells excel formula... One approach is to make the formula into text and then transform it by other formulas. When transformation is done, you could paste the formula back.
So for changing the D1 -> D11, I would build a dummy series (column K) then write a formula (cell L1). Then I can copy the formula and paste it into the correct column.
Replaceing the "=", with a special character and then you can transform the formulas.
(Column F).
In Column I, the formula used is: =RIGHT(F1,LEN(F1)-FIND("/",F1))
For changing D$1 -> D$100, I think I just would copy and replace it by searching in "Formulas".
This approach can be feasible for acouple of hundred cells. If the list is very long, I would recommend some VBA solution, where you can grab a cells formula with .Range("A1").Formula

Treating wildcards at standard characters in an INDEX(MATCH(COUNTIF())) formula

I am using the formula:
=(INDEX($A$2:$A$300, MATCH(0, COUNTIF($B$1:B1, $A$2:$A$300), 0))
This takes a list of values from column A and reproduces it in column B to show each value only once, i.e. if a value is duplicated, it gets skipped.
For the most part it is working exactly as I hoped, however, some of the values in column A contain the wildcard character '?'.
Is it possible to get this formula to treat the '?' as just a standard character? Ideally I would like to include this rule in the formula itself rather than having to do a 'find and replace' with '~?'. Is this at all possible?
Many thanks
Change your formula to:
=(INDEX($A$2:$A$300,MATCH(0,COUNTIF($B$1:B1,SUBSTITUTE($A$2:$A$300,"?","~?")),0)))
confirmed with ctrl+shift+enter
This replaces the ? in the criteria array with ~? within your formula.
You need to "escape" those characters. This is done the same as when searching in Excel, by prepending them with the tilde character: ~
So this searches for the question mark:
=MATCH("~?",A1:A10,0)

Excel: Specify sheetname in another cell for countif formula

My intention is to use the indirect formula. Here is the code I want to edit:
=COUNTIF('sheetname'!R:R;"x")
This code gives a #ref! error:
=INDIRECT("COUNTIF('"&D85&"'!R:R;"&B98&")")
Cell D85 contains sheetname and B98 contains "x".
My version of Excel needs ; in formulas instead of ,.
Thanks in advance for your expertise and time.
Try this formula:
=COUNTIF(INDIRECT("'"&D85&"'!R:R");B98)
My read on Indirect says that it simply uses the cell reference contained in the cell you specify in the function:
Indirect( cellContainingReference )
In this case, you don't need to specify the second parameter of Indirect.
So, using the assumptions:
sheetName is in cell D85
cellRange is always R:R
criteria for counting is in cell B98 (which does not need Indirect to work)
Your excel uses ';' rather than ','
Your formula for CountIf would be:
=countif(indirect("'"&D85&"'!R:R"); B98)
With some modification it works, I hope this is a good compromise for you. The modified formula is
=COUNTIF(INDIRECT(E1); F1)
and in this case that E1 should contain something like
''sheetname'!R:R
(See the double apostrophes at the beginning.)
F1 should contain the "X" or other value you want to count.

How to test if cell contains specific text in formula

Consider the following formula for cell A1
=Assumptions!$F$25*Assumptions!Q25
How can I create a boolean function to test if A1 has a reference to the sheet Assumptions?
I know if this was simply a constant, I could use: =+ISNUMBER(SEARCH("assumptions",A1) but this doesn't work if the cell value is a formula.
Note I am using EXCEL 2010, so isformula() won't work
Thanks
What about two alternative approaches?
Do a find a replace on the = sign. This will force all of your formulas to text, then you can write a normal formula to do the SEARCH or FIND. Then reverse the formulas back. I usually do a find all = and replace with ^^^ - then just reverse with find all ^^^ and replace with =.
If the heart of your question is just to find the references, why not use "find" CTRL+F ensure that Look in: Formulas is elected (under Options...), and then use the Find All button. This provides a nice list of output.

Resources