I'm having trouble with the usage of Indirect function.
Here's what i'm looking for, I'm trying to create a dynamic vlookup based on the current tab.
=VLOOKUP(B3;'NH BBC'!$E$1:$Z$188;MATCH("Share Outstanding";'NH BBC'!$E$1:$Z$1;0);0)
My plan is to modify the 'NH BBC' by 'NH ' & RIGHT(CELL("filename");3) Supposing that the name of my tab is XXX_BBC.
I've tried to use indirect function but I'm not sure I'm on the good way.
Here's what I've tried:
=VLOOKUP(B3;INDIRECT("'" "NH " & "RIGHT(CELL("'" & "filename" & "'" & ");3)" & "!" & "E1:Z188");MATCH("Share Outstanding";'NH BBC'!$E$1:$Z$1;0);0)
Hope I've been clear.
Thanks in advance !
You are trying to concatenate some text with the results returned from a formula, but you are sticking the formulas in quotes, turning them into text. Furthermore, you are not keeping very good track of your text. There are quotes all over the place. Take this bit by bit in a seperate cell if need, slowly growing your formula from the inside out so you can insure everything is as expected. Right now it's a mess.
INDIRECT("'" "NH " & "RIGHT(CELL("'" & "filename" & "'" & ");3)" & "!" & "E1:Z188")
Should be:
INDIRECT("'NH " & RIGHT(CELL("filename");3) & "'!E1:Z188")
No need for all the complication.
I've finally found and this formula is working perfectly.
VLOOKUP($B3;INDIRECT("'NH "&RIGHT(CELL("filename");3)&"'!$G$1:$ZZ$9999");MATCH("SHARE_OUTSTANDING";INDIRECT("'NH "&RIGHT(CELL("filename");3)&"'!$G$1:$ZZ$1");0))
By the way the issue i've got is that the cell are changing when i'm using the formula in another tab. Is this possible to look the value i've obtained ?
Something like a F9 ?
Related
I have three formulas
(1) =(B2:B&"."&substitute(substitute(lower(C2:C),"jalan","jln")," ",""))
(2) =COUNTIF('Payment Configuration'!A:A,A2:A) + COUNTIF('Payment Configuration'!E:E,A2:A)
(3) = =IF(ISBLANK(B:B),,B:B & ", " & UPPER(C:C) & ", BANDAR PUTERI KLANG")
Guys, I want to dragging this formula's until the last row without using Array formula because if I convert this formulas into array somehow it is not working in my web app (which is written in Google App Script). So anyone can help me with this formulas. Thanks in advance
If you want them to only work on a line at a time you need to trim the range to one row only:
=(B2&"."&substitute(substitute(lower(C2),"jalan","jln")," ",""))
=COUNTIF('Payment Configuration'!A:A,A2) + COUNTIF('Payment Configuration'!E:E,A2)
=IF(ISBLANK(B2),,B2 & ", " & UPPER(C2) & ", BANDAR PUTERI KLANG")
With the first two, you could add ISBLANK like your 3rd example.
I am trying to enter a "=$M15-$N15" formula to cell A15. However, need to use variable (r) instead of 15 as I don't know that value until later in the code. Trying the below but it is not working. What am I doing wrong?
Range("A" & r).formula = "="$M" & r - "$N" & r"
after the code is run, I need to have a formula ($M15-$N15) in Cell A 15.
I suspect you're looking for the INDIRECT function. An example of this, based on your explanation, would look like:
=INDIRECT("M"&A1)-INDIRECT("N"&A1)
If you're actually looking for VBA, you could use the following:
Range("A" & r).formula = "=$M" & r & "-$N" & r
However, this makes me suspect this is part of some over-arching routine, and, without knowing more, I can only speculate there might be a better or more efficient method(s) for going about it.
The following formula works great for the most part. I found the solution to my first issue, which was how to return a value based on partial contents of another cell. Check out Scott Craner's solution. Works great! However, when I started entering numbers I get the #NUM! error.
=INDEX(C:C,AGGREGATE(15,6,ROW($C$1:INDEX(C:C,MATCH("zzz",C:C)))/(ISNUMBER(SEARCH(" " & $C$1:INDEX(C:C,MATCH("zzz",C:C)) & " "," " & A1 & " "))),1))
I'm thinking that I'm getting the error because there are "." in the string.
Any help would be appreciated.
The formula you have doesn't work in that case because of what Scott pointed out in his answer:
"The SEARCH will search for matches. The " " & and & " " make sure we are looking for the entire word, So we do not get false positives on things like eric and erica.."
You could remove those spaces from his formula, i.e.
=INDEX(C:C,AGGREGATE(15,6,ROW($C$1:INDEX(C:C,MATCH("zzz",C:C)))/(ISNUMBER(SEARCH($C$1:INDEX(C:C,MATCH("zzz",C:C)),A1))),1))
to make B5 return what you want - which is not a whole "word" but a part of A5, but as a caveat that might allow for false positives. Row 5 is not the same scenario as 1-4. So take this answer with a grain of salt, depending on your data.
With the help of teylyn's answer in my previous question, the lowest value in the row are successfully highlighted. How to get the column letter to be displayed in the last column?
FROM
TO
=Left(if($C4=Min($C4:$I4),$C$3&" & ","")&if($E4=Min($C4:$I4),$E$3&" & ","")&if($G4=Min($C4:$I4),$G$3&" & ","")&if($I4=Min($C4:$I4),$I$3&" & ",""),LEN(if($C4=Min($C4:$I4),$C$3&" & ","")&if($E4=Min($C4:$I4),$E$3&" & ","")&if($G4=Min($C4:$I4),$G$3&" & ","")&if($I4=Min($C4:$I4),$I$3&" & ",""))-3)
Its ugly...really ugly. But it does work. Put that monstrosity in J4 and copy down.
where to begin with the description, I thought ugly and monstrosity covered it! Basically what the whole formula is doing is checking each number in the row to detemine if it is the minimum in the row. When that condition is true, it returns the value in the header row for that number and tacks on a " & " to it. It then moves on to the next column and performs the same check and adds the results to the previous column. When a number is not the minimum it adds "" to the results which is nothing. After going through all the results and building up a string that will end in "&" we pull the left side of the string, by the length of the string minus 3 characters to remove that last " & ".
Proof of concept
Like said in the comments of Forward Ed's answer, you could shorten the LEN-part with COUNTIF which would look like this:
=LEFT(IF($C4=MIN($C4:$I4),$C$3&" & ","")&IF($E4=MIN($C4:$I4),$E$3&" & ","")&IF($G4=MIN($C4:$I4),$G$3&" & ","")&IF($I4=MIN($C4:$I4),$I$3&" & ",""),COUNTIF($C4:$I4,MIN($C4:$I4))*4-3)
Still I would prefer the MID solution to (partially) skip any check of length like this:
=MID(IF($C4=MIN($C4:$I4)," & "&$C$3,"")&IF($E4=MIN($C4:$I4)," & "&$E$3,"")&IF($G4=MIN($C4:$I4)," & "&$G$3,"")&IF($I4=MIN($C4:$I4)," & "&$I$3,""),4,20)
The way it works should be pretty obvious. However, if there are any questions left, just ask :)
I have the following indirect reference:
=AVERAGE(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3))
On 'Pages'!D3 I have another page '1D_3' and on 'Pages'!J3 I have 2:2.
I need to alter the above code to instead find the average of the differences between each successive value. I can only change the value in 'Pages'!J3 (2:2) and I can change the equation above.
From this reference http://www.excelforum.com/excel-general/742194-difference-between-consecutive-number.html I have come up with how I can do the difference between each successive, but only if I have a known range. Ex. For elements A1:G1,
=SUM(A1:F1-B1:G1)
I could then do the following for the average:
=SUM(A1:F1-B1:G1)/(COUNT(1:1)-1)
But I do not know how to do the SUM part if I have an unspecified range. I also am unsure of how to implement this in the INDIRECT function.
Just some additional background info that may clarify this, The values in the array are times from a stopwatch. It was assumed that each value would be a time difference, but instead it is just the time on the stopwatch (Ex. 0.0015, 1.0034, 2.356, etc.). I want to find the average time duration between each value.
Any help would be greatly appreciated.
Before solving the formula you seek, let me just point out that all you need is the (EndValue-StartValue)/NumberOfEntries - no need to calculated the difference of each timing point first, as this will cancel itself out in the final calculation anyway.
Now assuming that Pages!J3 still only contains the row number, i.e. the formula =INDIRECT("'" & Pages!D5 & "'!" & Pages!J3) will return you a reference to this row. In the following formula, I use X as an replacement for the INDIRECT formula, to make it more readable:
=(OFFSET(X,0,0,1,1)-OFFSET(X,0,COUNT(X),1,1))/COUNT(X)
Now you only need to replace X with the above formula - or simply add a named range with the formula. If you combine it, you'll end up with this formula:
=(OFFSET(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3),0,0,1,1)-OFFSET(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3),0,COUNT(X),1,1))/COUNT(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3))
I tried what the other poster suggested and it did not work, even when replacing the remaining 'X'. I worked through a few other examples in Excel to finally come to the following conclusion. To not let this be lost to the sands of the internet, I decided to post my own solution. So I wanted an average of the differences between time values. Essentially, I wanted a sum over the total number of times (mean). The difficulty was in the indirect referencing and INDIRECT referencing within an INDIRECT reference.
So what I had was data on multiple worksheets, pages (Pages on B through E columns) and ranges (Pages on J column) on another worksheet, and the resulting operations on another sheet.
=SUM(INDIRECT("'"&Pages!D5&"'!C2"):INDIRECT("'"&Pages!D5&"'!"&SUBSTITUTE(ADDRESS(2,COUNTA(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3)),4),"1",""))-INDIRECT("'"&Pages!D5&"'!B2"):INDIRECT("'"&Pages!D5&"'!"&SUBSTITUTE(ADDRESS(2,COUNTA(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3))-1,4),"1","")))/(COUNT(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3))-1)
To break this into parts, we have:
=SUM(junk)/COUNT(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3))-1
And the 'junk' part is as follows. Ultimately, it was in the form:
=SUM(A1:F1-B1:G1)
Without INDIRECTs, if we had a page of data named '8D_2FU':
=SUM('8D_2FU'!C2:AW2-'8D_2FU'!B2:AV2)/(COUNT('8D_2FU'!2:2)-1)
Note that for this implementation we pick a maximum column on AW which was fine for all possible datasets.
There is also one more part of interest in the 'junk'. You cannot make an INDIRECT reference within an INDIRECT reference, so to fool Excel, we can use the SUBSTITUTE command and get the same result by converting the address contained in the INDIRECT reference.
SUBSTITUTE(ADDRESS(2,COUNTA(INDIRECT("'" & Pages!D5 & "'!" & Pages!J3)),4),"1",""))
Finally, to use this, you must make this an array operation by instead of typing 'Enter' you must type, CTRL+SHIFT+Enter. The result was also confirmed using a brute force test case.