I am trying to create a decoding macro. I have different combinations of letters in each cell on one sheet. For example, in cell B2 I would have something like "ABC." On a different sheet I have a table that matches letters to numbers, so I want the output in the new cell to be "123" in that case. I know how to use VLOOKUP on an entire cell, but cannot figure out how to use it on individual parts and then concatenate the results back together in the new cell.
This is what I've figured out so far. I think I need INDIRECT as part of it so I can reference the cell, but I cannot figure out how to look up the different portions of the cell. I do not want to create new columns to split the letter combinations up if possible.
=IFERROR(VLOOKUP("not sure??",'Conversion Table'!A4:B19,2,FALSE),"")
Thanks!
I'm assuming your cell B2 is limited to 3 chars only, and it's the same everywhere. In this case, you can do:
=CONCATENATE(VLOOKUP(MID(B2,1,1),'Conversion Table'!$A$4:$B$19,2,0),VLOOKUP(MID(B2,2,1),'Conversion Table'!$A$4:$B$19,2,0),VLOOKUP(MID(B2,3,1),'Conversion Table'!$A$4:$B$19,2,0))
If you have more chars, only add them using concatenate and select them one by one using MID.
Edit - locked the lookup table.
I think what you may be looking for is this:
A B C D
1 =""
2 ABC =IFERROR(VLOOKUP( =D1&C2
B2,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
3 XYZ =IFERROR(VLOOKUP( =D2&C3
B3,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
4 PQR =IFERROR(VLOOKUP( =D3&C4
B4,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
5 DEF =IFERROR(VLOOKUP( =D4&C5
B5,
'Conversion Table'!$A$4:$B$19,
2,FALSE),"")
The "Final Answer" appears in cell D5
Related
I am trying to use a sumif where the criteria is that column B equals 1 or 11:
=SUMIFS(A:A,B:B,{1,11})
The formula above works perfectly. But now what I would like to do is store {1,11} in a cell (e.g. cell C1). Then:
=SUMIFS(A:A,B:B,C1)
This no longer works, and it seems to pull up C1 as "{1,11}". Even though there are no visible quotes in cell C1, when I highlight C1 and press F9 in the sumif formula, quotes do come up.
Is there any way to do this? I want to be able to set the array {1,11} as a variable in a separate cell, because this could change. I do not want it hardcoded within the sumifs formula.
Thanks!!
Place your desired lookup in C1 and down, this is dynamic
=SUMPRODUCT(SUMIFS(A:A,B:B,C1:INDEX(C:C,MATCH(1E+99,C:C))))
Just make sure there are no other numbers in column C and the list is contiguous.
One possibility is you can use text in C1:
'{1,11}
And then define a name to convert it to an array:
EvalC1 refers to
=EVALUATE($C$1)
Note you can use the name in your array formula:
=SUMIFS(A:A,B:B,EvalC1)
I have a spreadsheet that has columns for dates and the values can be either "1v, .5v, 1p, .5p, 1s, .5s"
I have 3 columns in each row one for each letter "v, p and s". I want to be able to add the total of all cells in the range grouped by letter and then display the sum for each letter in it's respective column (v, p or c).
Here is an example of the sheet:
Name Vacation Personal Sick 1/5/15 1/6/15 1/7/15 1/8/15
Billy 1.5 1 0 .5v 1v 1p
It is the formula that goes in the vacation/personal/sick cell that I just can't figure out.
I went down the array formula route and came up with essentially the same formula as #Sancho.s :-
=SUM(LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v"))
You could modify it to take account of blanks:-
=SUM(IF($E2:$H2<>"",LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v")))
Perhaps this would be better, to ignore any mis-formatted cells:-
=SUM(IFERROR(LEFT($E2:$H2,LEN($E2:$H2)-1)*(RIGHT($E2:$H2)="v"),0))
These all have to be put in with Ctrl-Shift-Enter.
Assuming the range you posted starts at A1, use
=SUMPRODUCT((RIGHT($E2:$G2,1)="v")*LEFT($E2:$G2,LEN($E2:$G2)-1))
in B2. Change "v" and the range to use suitably.
Pro:
It is not an array formula. See why this may be important
Con:
I could not make it work with blank cells.
This "array entered" version will also allow blanks
=SUM(IF(RIGHT(E2:G2)="v",SUBSTITUTE(E2:G2,"v","")+0))
confirmed with CTRL+SHIFT+ENTER
I've got a weird Excel problem that is giving me a mind block. Basically, this is what I've got:
Column A contains strings of text, which all contain company names and a bunch of other info. I'd like to strip out those names. I've got a list of the names I'm searching for.
**Contractor**
CompanyA
CompanyB
CompanyC
CompanyD
And strings like this:
CompanyA REQ# G-FMR-036 PT 2
CompanyA Pad AN Structural Steel ()
COMPANYC REQ# 54
CompanyA REQ# G-FMR-049
What I would like is the formula to return whichever of the company names appears in that string. My first thought was a giant nested formula of IFs and SEARCHes but I know there has to be a better way.
With the list to search in A1:A4 and the list of company names in B1:B4, this array formula, entered with CtrlShiftEnter will do it:
=INDEX($B$1:$B$4,MATCH(TRUE,ISNUMBER(SEARCH($B$1:$B$4,A1)),0))
A bit of a kludge but better than nested IFs:
I am explaining for the example you gave above (4 companies); you should be able to figure out how to extend this.
In column A have your strings that include company names and the extra stuff. Let's assume A1 has some column title, and your 4 strings are in A2, A3, A4, A5.
In cells C1, D1, E1, F1 have the "clean" four company names.
In C2 have this formula:
=IF(ISERROR(FIND(UPPER(C$1), UPPER($A2))),"",C$1)
Then copy cell C2 to all the cells in C2:F5 . The formula will update automatically to fit each cell.
Then, in cell H2 have this formula:
=C2&D2&E2&F2
and then copy/paste it to H3, H4, H5.
In column H you will get what you are looking for.
Of course this assumes you have only one matching company name in each cell in column A, and that the names are exactly (up to case-sensitivity) the same as the company names in cells C1:F1 .
I take it that some of the company names contain spaces, otherwise you could just use:
=left(a1,find(" ",a1)-1)
If you need to compare the contents of the string against a list of companies, then with the list in a named range "CompanyList"; one entry per row; you could try something like:
=IFERROR(LOOKUP(2,1/ISNUMBER(SEARCH(CompanyList&"*",A1)),CompanyList),"Not in List")
However, if some names are similar, you will need to pay attention to the order in the list, as the formula will return the last entry that matches. So you want to put the longest string in Company List last.
This is what I've created so far, although I imagine there has to be a better way than nested formulas like whoa. I mean, it works, but it makes me want to cry.
=IF(ISNUMBER(SEARCH(T$3,B3)),"CompanyA",IF(ISNUMBER(SEARCH(T$4,B3)),"CompanyB",IF(ISNUMBER(SEARCH(T$5,B3)),"CompanyC",IF(ISNUMBER(SEARCH(T$6,B3)),"CompanyD","Other"))))
I need a formula that will look up a value in a 2-dimensional range and return the coordinates or cell address of the matching cell. For example:
R A B C
1 John Matt Pete
2 Sara Bret Chad
3 Lila Maya Cami
I want to search the range A1:C3 for Chad and return C2 or 2,3. How can I accomplish this using Excel formulas? (I'll actually end up applying this to Google Sheets).
Thanks!
Old question, but I thought I'd share a much simpler and elegant answer here that doesn't involve helper columns or complicated formulas, so that more people will get things done easier. Assuming that the table contains unique values and that you use E1 to store your search string Chad and E2 to display the result:
if you want the row and column result of 2,3 in E2:
=SUMPRODUCT((A1:C3=E1)*ROW(A1:C3)) & "," & SUMPRODUCT((A1:C3=E1)*COLUMN(A1:C3))
if you want the R1C1 style cell address string of C2 in E2:
=ADDRESS(SUMPRODUCT((A1:C3=E1)*ROW(A1:C3)),SUMPRODUCT((A1:C3=E1)*COLUMN(A1:C3)))
if you want the found cell's contents of Chad in E2:
=INDIRECT(ADDRESS(SUMPRODUCT((A1:C3=E1)*ROW(A1:C3)),SUMPRODUCT((A1:C3=E1)*COLUMN(A1:C3))))
How things work:
SUMPRODUCT returns in this case the sum of the products between a boolean array of TRUE (searched value found in cell) and FALSE (searched value not found in cell) for every cell in the table and the corresponding row/column (absolute) numbers of those cells in the sheet; thus, the result is essentially the row/column (absolute) number of the cell where the value has been found, since TRUE=1 and FALSE=0 in mathematical terms
ADDRESS returns a cell's address as text (not as reference!)
INDIRECT returns the reference corresponding to a cell's text address
Source and credit goes to: this answer by XOR LX. Could have added the link in a comment, mentioning the duplicate question, but I wanted to expand and explain the answer a little bit, therefore more characters were needed.
Assuming you're using Excel 2007 and above.
You will need a helper column. If your table looks like in your example, in cell D1 write:
=IFERROR(MATCH($E$1,$A1:$C1,0),0)
And drag it down. Then in cell E1 write your search value ("Chad" for instance). Then you have your search result in cell E2 with this formula:
=IF(MAX($D:$D)=0,NA(),MATCH(MAX($D:$D),$D:$D,1)&","&MAX($D:$D))
If you want a simpler solution, it is possible to use only one helper (or not at all, at the cost of a complicated formulae).
Let's say I take your example. I will use the D column to display result :
In D1, I put the name I want to find : Chad
In D2, I put the helper that will return an Index of the value searched (-1 if not found) : =IFERROR(MATCH(D1,SPLIT(TEXTJOIN(";",TRUE,A1:C3),";"),0),-1)
In D3, I put the formulae to get the row,column value (FALSE if not found) : =IF(D2<>-1,ROUNDUP(DIVIDE(D2,COLUMNS(A1:C3))) & "," & IF(MOD(D2,COLUMNS(A1:C3))=0,COLUMNS(A1:C3),MOD(D2,COLUMNS(A1:C3))))
If you really want to use only one formulae, it is possible in D3 to replace all references to D2 by the formulae used in D2.
This formula returns the row and column number of a given value in a two-dimensional array.
=LET(
array, B2:D4,
findvalues, C7,
arrayrows, ROWS(array),
arraycols, COLUMNS(array),
rowindex, SEQUENCE(arrayrows*arraycols,,1,1/arraycols),
colindex, MOD(SEQUENCE(arrayrows*arraycols,,0),arraycols)+1,
flatarray, INDEX(array,rowindex,colindex),
valueflatindex, MATCH(findvalues,flatarray,0),
valuerow, ROUNDUP(valueflatindex/arraycols,0),
valuecol, MOD(valueflatindex-1,arraycols)+1,
absvaluerow, MIN(ROW(array))+valuerow-1,
absvaluecol, MIN(COLUMN(array))+valuecol-1,
CHOOSE({1,2},absvaluerow,absvaluecol)
)
A B C D E
1
2 John Matt Pete
3 Sara Bret Chad
4 Lila Maya Cami
5
6
7 find: Chad
8 formula: 3 4
More precisely, this formula scans a given array row by row and returns the address of the first occurrence of a given value.
If you need the row and column numbers relative to the array's top left cell, then in CHOOSE(...), instead of absvaluerow/absvaluecol, use valuerow/valuecol.
If you want the values to be comma separated and in one cell, instead of CHOOSE(...), use absvaluerow & "," & absvaluecol
If your Excel version does not support the latest functions, such as LET, the formula should still work if you rewrite it so that it does not use the LET variables.
Find Multiple Values
You can also find multiple values in an array using this formula as explained in my answer in this thread.
I am very familiar with vlookup and hlookup functions in Excel. However, I am looking for a method of doing both. Take this example:
A B C
1 Resources
2 Task Mgr Sr. Mgr
3 -----------------------------
4 Task 1 30% 70%
5 Task 2 40% 60%
6 Task 3 50% 50%
7 Task 4 70% 30%
If I wanted to put a formula in a new cell to look up both a task and a resource type to return the appropriate percentage, how could I do this?
A combination of INDEX and MATCH will do the trick:
=INDEX($B$4:$C$7,MATCH("Task 3",$A$4:$A$7,0),MATCH("Mgr",$B$2:$C$2,0))
Another possibility:
=VLOOKUP(E3,A2:C7,MATCH(E2,A2:C2,0),FALSE)
Where
E3 contains the task to look up
E2 contains the header column name
(eg Mgr)
A2:A7 is the table of data
A2:C2 is the header
Okay, assume you have an Excel sheet with the following format where your lookup table occupies the cell range A1:E5
C1 C2 C3 C4
R1 R1C1 R1C2 R1C3 R1C4
R2 R2C1 R2C2 R2C3 R2C4
R3 R3C1 R3C2 R3C3 R3C4
R4 R4C1 R4C2 R4C3 R4C4
Also assume you want to enter the row header name and column header name into cells G3 and H3 respectively (which I have the text values "R3" and "C2").
In the cell you wish to display your output value, you could either use HLOOKUP like so:
=HLOOKUP(H3,A1:E5,MATCH(G3,A1:A5,0))
or VLOOKUP like so:
=VLOOKUP(G3,A1:E5,MATCH(H3,A1:E1,0))
Either displays the value "R3C2" in my output cell.
=OFFSET(A3,MATCH("Task 3", A4:A7, 0),MATCH("Mgr",B2:C2,0))
Of course, you're probably getting the things to look for from other cells, so replace "Task 3" and "Mgr" above with references to those cells.
Okokokok so
I just figured out an alternate, much simpler answer... its an IF function!
so okay, what I mean by this is the following;
you have 2 input cells, both formatted with data validation lists. One has the tasks, and one has the position, as shown in the question asked.
now we use a vlookup function to determine what row we are going to get, and then an IF function to determine the column!!
now lets say your input cells are next to each other at E1 and F1
So an example of this formula would be,
=vlookup($E$1,$A$4:$C$7,IF($F$1="MGR",2,3),FALSE)
This works so well and can even be used with more than 2 columns by using the IFS Function!
I Hope this helps some kid in the future who did exactly what I did and went to the internet for answers after being very confused hahaha