I have a working array formula, which creates a list of values in column A. The length of the list depends on the input values of the formula and will vary over time. Values could be removed and added anywhere in the list, not necessarily at the end. Now in column B I want to manually add comments on the values in column A. When the length of the list changes, the values in column B don't move along with the values in column A, so they are not longer on the correct line. Is there a way to solve this?
You can try to use the OFFSET function for the dynamic variable.
Related
I have the following formula which identifies a value on another sheet (called "Mold") in my excel file via VLOOKUP, then tells me the position inside array "Mold!C17:C116" and consequently looks for the value inside "table1" taking into consideration the row position from the MATCH function and column 2 inside the INDEX function:
INDEX(table1,MATCH(VLOOKUP($B$17,Mold!$B$5:$AZ$181,C$8+1,FALSE),Mold!C17:C116,0),2)
The sheet I have this formula in changes the values according to a dropdown list (located in "C$8"). What I am trying to achieve is that the array "Mold!C17:C116" adjusts according to the column where the value of the VLOOKUP is found. For example, if the value is found in column X, tell me the position of it in the array located in the same column X17:X116, if value was found in column Y, look for position in array within the same column Y (rows 17 to 116 should always remain the same).
How can I make the array and VLOOKUP work together in the same column?
Thanks in advance for the help, and please let me know if something is not clear enough.
The formula presented above is what I´ve tried but it only works in one column, as I pull formulas to the right to other columns, it only looks for values in that one specific column and not in the same column as its VLOOKUP Value.
I wish to create a helper cell using a dynamic array, Is this possible?
Normally I use a formula such as in this example =IF(A4="",C2,A4) which check if column A is blank and if so just copies the above value until a new value appears in column A.
However as shown in the image when I insert New rows the helper cell becomes broken.
For this reason I wanted to use a dynamic array to create the helper cell which should be able to handle rows inserted or removed.
The problem I have is that unlike a normal formula which you can just drag down, a dynamic array is looking at the values as a whole. Using =IF(A4:A40="","-",A4:A40) inserts a hyphen as shown in the image. Essentially I wish to replace the hyphen such that "For each value between A4:A40 check if blank and if true take the value in the above cell". In essence creating a dynamic helper column.
You can use the inexact form of Match to find the last row which is not blank, and then Index to take the value in column A from there:
=INDEX(A4:A40,MATCH(ROW(A4:A40),IF(A4:A40<>"",ROW(A4:A40))))
This sort of thing is done a lot in Google Sheets.
If you insert a row, the formula changes to
=INDEX(A4:A41,MATCH(ROW(A4:A41),IF(A4:A41<>"",ROW(A4:A41))))
and still works OK.
I'm looking for a way to search within the cells in a range for a specific text value, and have them returned sorted by those values along with the corresponding cell in the next column over. For example, in column A I have the description of the item, and in Column B there is a number value:
Unsorted
These describe that particular formats (Col A) and how many of each (Col B). So what I'm looking to do is sort by multiple format, "K-7.75" and "K-20L" for example, and then return that cell along with the corresponding Column B. Is there a way I can write this all in one formula, searching for multiple strings within Col A? Here's what I'd like the output to look like, with the formulas being in A1, A9, and A13:
Sorted
I know there is a filter option, but I cant seem to use multiple strings in that and I'm looking to eliminate steps in reordering this info. I feel like there's a way to do this with Array and Search or Sort or something, but I'm stuck. Thank you in advance for any help.
Solved thanks to Kessy:
Do you know in advance the conditions you will get like "k-7.75"? If that is the case you can set every x rows or every x columns the following filter function: =FILTER(A:B, REGEXMATCH(A:A,"K-7.75")) – Kessy
=FILTER(A:B, REGEXMATCH(A:A,"K-5.16|1/6|K-20|20L|K-7.75|1/4|K-30|30L")). Using the operator character "|" as an OR logic. Thank you for putting me on the right track! – MisterSixer
How do I convert a string from a cell to a text array inside of a function, that should use the array, without using VBA and without adding the array into any other part of the document? It will be one of these arrays on more than 1000 rows. The string format is ^[a-zA-Z0-9.,-]*$ with "," as delimiter.
This is the functionality I would like to achieve
I have an excel table with the following columns
A: ID numbers to compare, separated by comma (delimiter can be changed if needed). About 100 ID's would be good to support at least.
B: ID (Each value on the rows in the column are unique but not sorted and can't be sorted because sorting is needed based on other criterias)
C: Value (Several rows in the column can have the same value)
D: Output the one ID of the comma separated ID's that has the highest value on its row
The problem part of the output
So far I have made a function which find the correct ID in column B based on the values in column C but only if I enter the string from column A as an array constant manually within the function. I have not managed to get the function to create the array itself from column A, which is required.
Working part of the code
In this code I have entered the values from column A manually and this is working as it should.
=INDEX({"1.01-1","1.01-3","1.08-1","1.01-1-1A"},MATCH(MAX(INDEX(C$10:C$20,N(IF(1,MATCH({"1.01-1","1.01-3","1.08-1","1.01-1-1A"},B$10:B$20,0))))),INDEX(C$10:C$20,N(IF(1,MATCH({"1.01-1","1.01-3","1.08-1","1.01-1-1A"},B$10:B$20,0)))),0))
Note that the start row is not the first row and the array is used 3 times in the function.
Code to try to convert the string to a text array
Not working but if wrapped in SUMPRODUCT() it provide an array to the SUMPRODUCT() function, of course not usable since I then can't pass on the array. The background to this code can be found in question Split a string (cell) in Excel without VBA (e.g. for array formula)!.
=TRIM(MID(SUBSTITUTE(A10,",",REPT(" ",99)),(ROW(OFFSET($A$1,,,LEN(A10)-LEN(SUBSTITUTE(A10,",",""))+1))-1)*99+((ROW(OFFSET($A$1,,,LEN(A10)-LEN(SUBSTITUTE(A10,",",""))+1)))=1),99))
The second code output the first item of the array and inserted in the first code do not change this result as it did when wrapping the second code in SUMPRODUCT().
Here is a picture of my simplified test setup in Excel for this case, identical to what is described above.
Simplified test setup
I'm not really sure what you are doing with your formula.
But to convert contents of a cell to a comma separated text array to be used as the array argument to the INDEX or MATCH functions, you can use the FILTERXML function. You'll need to educate yourself about XML and XPATH to understand what's going on, but there are plenty of web resource for this.
For example, with
A10: "1.01-1","1.01-3","1.08-1","1.01-1-1A"
The formula below will return 1.08-1. Note the 3 for the row argument to the INDEX function.
=INDEX(FILTERXML("<t><s>" & SUBSTITUTE(SUBSTITUTE(A10,"""",""), ",", "</s><s>") & "</s></t>", "//s"),3)
I have a table in Matlab crsp and and cell array of numbers that serve as keys. I want to retrieve information from the table using that cell array which is stored as a variable. My code is as follows:
function y = generateWeights(permno_vector, this_datenum, crsp)
crsp(crsp.PERMNO == permno_vector,:);
crsp is defined as a table while permno_vector is the cell array. It contains a couple permnos that are used to retrieve information.
In this case, my code is not working and will not allow me to access the values in crsp. How do we access table values using a vector array?
As James Johnstone points out, the first problem with the code you've posted is that it doesn't assign anything to y, so as written your function doesn't return a value. Once you've fixed that, I assume the error you are seeing is Undefined operator '==' for input arguments of type 'cell'. It's always helpful to include this sort of detail when asking a question.
The syntax
crsp(crsp.PERMNO == x,:)
would return those rows of crsp that had PERMNO equal to x. However if you want to supply a list of possible values, and get back all the rows of your table where your target variable matches one of the values in the list, you need to use ismember:
crsp(ismember(crsp.PERMNO, cell2mat(permno_vector)),:)
if permno_vector is a cell array, or simply:
crsp(ismember(crsp.PERMNO, permno_vector),:)
if you can instead supply permno_vector as a numeric vector (assuming of course the data in crsp.PERMNO is also numeric).