I have an Excell in which one of the rows looks like the following:
09001 | 09003 | 09017 | 173018 | 8199
09001 | 81009 | 173005 | 6709 | 15005
Now, what I need is a formula for a cell that will check if I have some specific values (For example, 09003 and 173005) and copy them to the actuall cell.
The values I look for won't be repeated, It will be just one of them in the cell, that should make it easier but I havent been lucky trying...
Result expected per examples above:
| 09003 |
| 173007|
This is my answer:
Formula for 9003:
=IFERROR(IF(FIND($B$1,A2)>0,B1,0),"-")
Formula for 173007:
=IFERROR(IF(FIND($C$1,A2)>0,C1,0),"-")
Results Structure:
Formula for both number in one cell:
=IFERROR(IF(FIND("9003",A1)>0,"9003",0),"-") & " " & IFERROR(IF(FIND("173007",A1)>0,"173007",0),"-")
Result:
For example, "09003" can be extracted using the following Excel functions:
Say B3 is cell containing source string:
09001 | 09003 | 09017 | 173018 | 8199
Then:
// find start of target string
B4 contains formula 1 [ =LEFT(FIND("09003",B3)) ] // "09003" could also be passed as a cell reference
// find end of target string
C4 contains formula 2 [ =RIGHT(FIND("|", B3, B4)) ]
// extract string using endpoints
D4 contains result [ =MID(B3, B4, (B4-C4)+1) ]
Related
I want to get just the number after the last underscore (_). How do I do that without splitting the string with the comma as a delimiter?
PSN_IDA8_776 = need to get 776
NXXT_FAEMNE_7905 = need to get 7905
PCBA_SAN_LUIS_441B = Need to get 441B
MCOM_LUX_415_U = need to get 415U
The following is working for PSN_IDA8_776
=RIGHT(I9,FIND("_",I9)-1)
but same formula not correctly working for ABCA_SEA_3_SFA_809
Try
=MID(A1,FIND("|",SUBSTITUTE(A1,"_","|",LEN(A1)-LEN(SUBSTITUTE(A1,"_",""))))+1,LEN(A1))
Broken down into separate formula:
C1: =LEN(A1) - find the length of the original string.
D1: =LEN(SUBSTITUTE(A1,"_","")) find the length of the string with the underscore removed.
E1: =C1-D1 will return the number of underscores in the string.
F1: =SUBSTITUTE(A1,"_","|",E1) - substitute the last underscore with an I-bar.
G1: =MID(A1,FIND("|",F1,E1)+1,LEN(A1)) - pull out the characters after the last underscore.
or for a VBA solution:
Public Function After_Underscore(Target As Range, Optional Delimiter As String = "_") As Variant
Dim Last As Long
Last = InStrRev(Target, Delimiter)
If Last > 0 Then
After_Underscore = Mid(Target, Last + 1, Len(Target))
Else
After_Underscore = CVErr(xlErrNA) 'If no underscore return an #N/A error.
End If
End Function
Assume your data put in A1:A6
In B1 formula copied down :
=SUBSTITUTE(MID(A1,LOOKUP(9^9,FIND("_"&{1,2,3,4,5,6,7,8,9,0},A1))+1,99),"_","")
Edit:
As per Terry W's point out that the above formula will fail in string like : TEST_30_20_10_AB
Here is the testing data A1:A7, as same as Terry W's post mentioned
PSN_IDA8_776
NXXT_FAEMNE_7905
PCBA_SAN_LUIS_441B
MCOM_LUX_415_U
ABCA_SEA_3_SFA_809
TEST_30_20_10_AB
TEST_aa_20_bb_10
My revised formula in B1, copied down :
=SUBSTITUTE(MID(A1,AGGREGATE(14,6,FIND("_"&{1,2,3,4,5,6,7,8,9,0},A1),1)+1,99),"_","")
Result of the formula :
B1: 776
B2: 7905
B3: 441B
B4: 415U
B5: 809
B6: 10AB
B7: 10
The following solution requires the use of TEXTJOIN which is only available in Excel 365 and later versions.
=IF(RIGHT(TEXTJOIN("",0,--ISNUMBER(FILTERXML("<t><s>"&SUBSTITUTE(A1,"_","</s><s>")&"</s></t>","t/s"))),2)="10",SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A1,"_",REPT(" ",100),SUMPRODUCT(--(MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),1)="_"))-1),100)),"_",""),MID(A1,MAX(IFERROR(FIND("_",A1,ROW($A$1:INDEX($A:$A,LEN(A1)))),0))+1,LEN(A1)))
replace A1 to suit your case. It is an array formula so you MUST press Ctrl+Shift+Enter on your keyboard after entering it in the formula bar.
The main logic is to find out if the last two sub-string (followed by underscore _) is a combination of numeric + text. If so, return the combination of both sub-string, otherwise just return the last sub-string.
Here are the sample strings I have tested:
| Strings | Results |
|--------------------|---------|
| PSN_IDA8_776 | 776 |
| NXXT_FAEMNE_7905 | 7905 |
| PCBA_SAN_LUIS_441B | 441B |
| MCOM_LUX_415_U | 415U |
| ABCA_SEA_3_SFA_809 | 809 |
| TEST_30_20_10_AB | 10AB |
| TEST_aa_20_bb_10 | 10 |
I have an excel table, like this
| DOG | CAT | COW | CHICKEN ...
------+-----+------+------+------
FARM1 | 2 | 0 | 4 | 80
------+-----+------+------+-------
FARM2 | 0 | 3 | 12 | 125
------+-----+------+------+-------
......
Is it possible to get the value through the customer headers instead of A2, B2?
I want to be able to fetch the value like so
=FARM1DOG
Is it possible to do that?
What you are describing could be done a few ways. I would prefer index(match(...
Assuming your table above is in the top-left corner of the spreadsheet and continues to J10 you could use:
=INDEX($B$2:$J$10,MATCH("FARM1",$A$2:$A$10,0),MATCH("DOG",$B$1:$J$1,0))
On the other hand, you could do it with named ranges as well, but the names would need to be changed if the column headers changed. Just name each entire column after it's header. So select column B and create a name for the range called "Dog", then the same for all the other columns. Then for the rows name row 2 "Farm1", etc...
Then you can use:
=FARM1 DOG
(the space between them is the intersect operator)
Under presumption that your data is small you can also name the Range manually:
Select the cell you want to name
Formulas -> Define Name [ CTRL + SHIFT + F3 ]
Call it whatever you want
Now you can refer to the cell by the given name:
EDIT:
Alternatively, you could also name the headers only and refer to it via =OFFSET.
=OFFSET(<VERTICAL NAME>,,COLUMN(<HORIZONTAL NAME>) - COLUMN(<VERTICAL NAME>))
In a practical example
=OFFSET(farm1,,COLUMN(dog) - COLUMN(farm1))
+---+------------------+-----------------+---------+
| | A | B | C |
+---+------------------+-----------------+---------+
| 1 | Link Reference | Description | ID |
+---+------------------+-----------------+---------+
| 2 | Result | East Quad | 2 |
+---+------------------+-----------------+---------+
Hey guys,
In Excel, I want to output for cell A2 [Result] the following
East Quad
I'm using this formula below.
Result=IF(C2="2","B2,"Null")
However, after pressing enter I get an error...
Result=IF(C2="2","B2,"Null")
"https gets highlighted. I think this is occurring because Excel is interpreting href= as a formula.
I thought maybe adding before it something as TEXT() or STRING() would work, but I wasn't able to get anywhere.
Does anyone know what I could add in order for this error not to prop up, or could it also be a setting within the application that needs to be adjusted?
Thank you!
In A2 enter:
=IF(C2="2","" & B2 & "","Null")
This formula assumes that the cell C2 contains a Text 2 rather than a Numeric 2.
Please note the usage of the double quotes.
I want to return a label(s) based on an intersection of a Row and Column equal to "Yes".
| Location |
ID | Tool | Wall | Bin | Toolbox | Count
---+--------+------+-----+---------+-------
1. | Axe | YES | | | 1
2. | Hammer | | | YES | 5
3. | Pliers | | | YES | 2
4. | Nails | | YES | | 500
5. | Hoe | YES | | | 2
6. | Screws | | YES | | 200
7. | Saw | YES | | | 3
What's in Toolbox? (Results wanted)
Axe,Wall, 1
Hammer, Toolbox, 5
Pliers,Toolbox, 2
Nails,Bin, 500
Hoe, Wall, 2
Screws, Bin, 200
Saw, Wall, 3
I also want to be able add Tools and Locations?
Without using VBA, this is going to be a bit of a pain, but workable if you don't mind helper columns. I don't advise trying to do this in a single Array Formula, because text strings are hard to work with in Array formulas. That is - if you have an array of numbers, you can turn that into a single result a lot of ways (MIN, MAX, AVERAGE, SUM, etc.). However with an array of strings, it's harder to work with. Particularly, there's no easy way to concatenate an array of strings.
So instead, use a helper column. Assume column A = toolname, column B = a check for being on the wall, column C = a check for being in the bin, column D for being in the toolbox, and column E for the number available.
FORMATTING SIDE NOTE
First, I will say that I recommend you use TRUE/FALSE instead of "yes"/"no". This is because it is easier to use TRUE / FALSE within Excel formulas. For example, if you want to add A1 + A2 when A3 = "yes", you can do so like this:
=IF(A3="yes",A1+A2)
But if you want to check whether A3 = TRUE, this is simplified:
=IF(A3,A1+A2)
Here, we didn't need to hardcode "yes", because A3 itself will either be TRUE or FALSE. Also consider if you want to make a cell "yes" if A3 > 5, and otherwise be "no". You could do it like this:
=IF(A3>5,"yes","no)
Or, if you used TRUE/FALSE, you could simply use:
=A3>5
However, I'll assume that you keep the formatting you currently have (I would also recommend you just have a single cell that says either "toolbox"/"bin" etc., instead of 4 columns where 1 says "yes", but we'll also assume that this needs to be this way).
BACK TO YOUR QUESTION
Put this in column F, in F2 for the first cell:
=Concatenate(A2," ",INDEX($B$1:$D$1,MATCH("yes",B2:D2,0))," ",E2)
Concatenate combines strings of text into a new single text string. You could also use &; like: A2 & " " etc., but with this many terms, this is likely easier to read. Index looks at your header row 1, and returns the item from the first column which matches "yes" in the current row.
Then put the following in F3 and drag down:
=Concatenate(F2," ", A2," ",INDEX($B$1:$D$1,MATCH("yes",B2:D2,0))," ",E2)
This puts a space in between the line above and the current line. If instead you want to make each row appear after a line-break, use this:
=Concatenate(F2,CHAR(10), A2," ",INDEX($B$1:$D$1,MATCH("yes",B2:D2,0))," ",E2)
I have a column of few thousand filenames that are not uniform. For instance:
| Column A | Column B |
===============================
| junk_City1_abunc | City1 |
-------------------------------
| nunk_City1_blahb | City1 |
-------------------------------
| small=City2_jdjf | City2 |
-------------------------------
| mozrmcity3_somet | City3 |
I would like to identify the city within the text in column A and return it in Column B.
I've come up with a complex formula that does the trick, but it is difficult to adjust if more cities are added within the filenames in new entries within column A.
Here is an example:
=IF(ISNA(MATCH("*"&$W$3&"*",I248,0)),IF(ISNA(MATCH("*"&$W$4&"*",I248,0)),IF(ISNA(MATCH("*"&$W$5&"*",I248,0)),IF(ISNA(MATCH("*"&$W$6&"*",I248,0)),IF(ISNA(MATCH("*"&$W$7&"*",I248,0)),IF(ISNA(MATCH("*"&$W$8&"*",I248,0)),"Austin","Orlando"),"Las Vegas"),"Chicago"),"Boston"),"Las Angeles"),"National")
It seems like there should be an easier way to do it, but I just can't figure it out.
(To make matters worse, not only am I identifying a city within the filename, I'm looking for other attributes to populate other columns)
Can anyone help?
Use the formula =IFERROR(LOOKUP(1E+100,SEARCH($E$2:$E$11,A2),$E$2:$E$11),A2)
This does *****NOT***** have to be array entered.
Where $E$2:$E$11 is the list of names you want returned and A2 is the cell to test
If no matches are found instead of errors you will just use the full name in column b.
If you want errors or expect to NEVER have then you can just use:
=LOOKUP(1E+100,SEARCH($E$2:$E$11,A2),$E$2:$E$11)
Here's a round about way that works, not all my own work but a mish mash of bits from other sources:
Assuming the sheet is setup as follows:
The formula to use is below, this must be entered using Ctrl+Shift+Enter
=INDEX($C$2:$C$8,MAX(IF(ISERROR(SEARCH($C$2:$C$8,A2)),-1,1)*(ROW($C$2:$C$8)-ROW($C$2)+1)))
Annotated version:
=INDEX([List of search terms],MAX(IF(ISERROR(SEARCH([List of search terms],[Cell to search])),-1,1)*(ROW([List of search terms])-ROW([Cell containing first search term])+1)))