MS Excel eval() like function - excel-2007

I am trying to find the best moving average and stumbled upon a problem.
I can create cells with content like B233:B253 based on a n. However, I am unable to paste this value to the AVG() function, which sees the value as a string.
Is there any kind of eval() function?
VBA is out of the game as I am going to use MS Solver.

there is a type of eval function - INDIRECT
Example
put 3 values in column A
put A1:A3 in B1
=AVERAGE(INDIRECT(B1)) will give you the average of cells A1:A3

Related

How to create a conditional match with index in Excel?

I am trying to use the match formula in XLS with multiple conditions, embedded within an index formula, to extract values from a sub-group as illustrated below. And without using the array function where you must enter in order to execute. I've used conditional matches before as described in https://exceljet.net/formula/index-and-match-with-multiple-criteria but in this example I'm at a loss as to how to do this:
Any suggestions?
Here is a solution that seems to work, after I fiddled around some more with index/match:
Use the formula IF(E20>0,E20,INDEX($E$20:$E$25,MATCH(1,INDEX((ROW()<>ROW($D$20:$D$25))*(D20=$D$20:$D$25)*($C$20:$C$25>0),0,1),0))) in the first row for this conditional index/match, then copy down to the entire length of the target array. Please see OP edit labeled with Here is a solution for a working example.

Performing multiple vlookup operation in VBA

I have a logical doubt. Is it possible to return a value to a cell by performing Vlookup operation in 3 sheets, i.e the value to be returned might be in one of the three sheets. If so how can I approach this? I am trying to create a macro using VBA.
if there are no real differences between the worksheets you can use formulas instead of VBA using =IFERROR() and =VLOOKUP()
An example would be:
=IFERROR(VLOOKUP(valueToLookFor,sheet1Range,columnNumber,FALSE),IFERROR(VLOOKUP(valueToLookFor,sheet2Range,columnNumber,FALSE),VLOOKUP(valueToLookFor,sheet3Range,columnNumber,FALSE)))
This would just perform the search on the first sheet, if the value isn't there it will return an error, hence looking in the following sheet etc.
Bear in mind I've written the formula given your Excel is in English with commas (",") as separators, you might need to translate it in you default language and separators.

Need a simple search function to display most common value in a column. (with ambiguous choices)

I have a very large array of data with many columns that display different outputs for the values presented. I would like to add a row above the data that will display the most common occurring value or word below.
Generally I would like to have each top of the column (right under the column label in row 1) have the most common value below. I will then use this value for various data analysis functions!
Is this possible, and if so, how? Preferably this will not require VBA, but simply a short code in the cell.
One caveat: The exact values may vary, so there is no set list where I can say "it will be one of these."
Any ideas appreciated!
Try a series of =COUNTIF(A:A,"VALUE TO SEARCH") functions if you want to stay away from VBA.
Otherwise, the best method would be to iterate through each column via VBA. With this method, you can even count the "varying" values and return the count and/or the value itself.
http://www.excel-easy.com/examples/most-frequently-occurring-word.html
This is a single formula you would write at the top of each column. Does not require VBA. You can replace the set range to an entire column, such as (A:A) instead of (A1:A7).
If you mean an array as in a data type, it could work differently but it depends what you're trying to do.
With data from A3 through A16, in A2 enter:
=INDEX($A$3:$A$16,MODE(MATCH($A$3:$A$16,$A$3:$A$16,0)))
This will work for text as well as numbers. Adjust this to match the column size.

Function that searches for the exact same date or the closest one in the past + one extra condition

This is a continuation of " Is it possible to write a VBA code that searches for the exact same data or the closest one in the past? "
Basically I would like to expand the function that #Jeeped posted but for some reason it's not going as planned eventhough I'm doing the same stuff he showed.
The extra condition in this case is that the machine used to produce the juice must be equivalent to the machine of the parameters.
(the image of what I'm doing)
Basically if a juice is made on 29/09 with machine M0 for example then I want to have the parameters that were used for that juice. Obviously the parameters of 30/09 weren't used but the parameters of 25/09 for machine M0 were used.
I edited the code #Jeeped posted in my previous question to the following
=IFERROR(INDEX(C$2:C$10, MIN(INDEX(ROW($1:$10)+($A$2:$A$10>$F2)*1E+99+($B$2=$G$2),,))),"")
But I get an error and I'm not sure why but I have a feeling it has to do with what I wrote ($B$2=$G$2) but how do I fix it?
DISCLAIMER: the percentages used are fictive, it's just a function I need to get working for several Workbooks that will automate some work I need to do every month.
It looks like you want to add the condition that columns B should match G2. This should do the trick.
=IFERROR(INDEX(C$2:C$10, MIN(INDEX(ROW($1:$9)+(($A$2:$A$10>$F2)+($B$2:$B$10<>$G2))*1E+99,,))),"")
This type of formula does not make direct matches. It excludes everything that doesn't match and then accepts whatever is left over. So like the date in F2 is compared to the dates in column A and anything that is larger (i.e. later) is multiplied by a very large number. We do the same to the machine ID in G2. Anything that does not match the machines in column B get multiplied by the same very large number. By mathematically excluding anything that doesn't fit, we are left with what does fit.
It is also important to note that the ROW(1:9) is the position within C2:C10 or A2:A10, not the actual row on the worksheet.
Addendum: With the dates now unsorted, I can provide both a standard and an array formula to compensate. The array formula for I2 is,
=SUMIFS(C$2:C$10,$A$2:$A$10,MAX(IF($A$2:$A$10<=$F2,IF($B$2:$B$10=$G2,$A$2:$A$10))),$B$2:$B$10,$G2)
This must be finalized with Ctrl+Shift+Enter rather than simply Enter. Once entered correctly, it can be filled both right and down. Next is a standard formula that does not require Ctrl+Shift+Enter but accomplishes the same thing. Your results should resemble the following image.
=SUMIFS(C$2:C$10, $A$2:$A$10,MAX(INDEX(($A$2:$A$10<=$F2)*($B$2:$B$10=$G2)*($A$2:$A$10),,)),$B$2:$B$10,$G2)
    
I think the formula below might answer your question. Please see the image for reference.
Formula Used: =INDEX($D$2:$E$7,MATCH(1,($B$2:$B$7<$H3)*($C$2:$C$7=$I3),0),1)
Please note - this requires your date of parameter change to be sorted from newest to oldest.
To apply this formula, press CTRL+SHIFT+ENTER after writing the formula. This is required for excel to understand that this should function as an Array formula. On doing so, excel will automatically add the curley brackets at the beginning and end of the formula as can be seen in the image.
Only small difference for formula to get %Oranges will be replacing the last 1 by 2.
INDEX($D$2:$E$7,MATCH(1,($B$2:$B$7<$H3)*($C$2:$C$7=$I3),0),2)
Hope this answers your question. Please let me know if you need further assistance.

How to create a dynamic function

I am trying to make a simple savings system and i have already set a simple function to calculate interest. The problem is the interest rate formula. Once the app will be deployed, the formula cannot be changed anymore. My plan is to store my formula in a database and retrive the formula everytime the interest function is called but the function treats the formula as string.
Is there any way to change how a function would work during runtime?