Excel Problem.
Let's say I have 2 cells.
A1: HE11294419-12
A2 11296581
I would like to extract the number after the dash found in A1, in another cell.
In case of A2 - the cell should say just "1".
So the result should be
B1: 12
B2: 1
Assumptions:
Always just one dash in string
In case no dash, extract the last number of string
Try in B1:
=IFERROR(MID(A1,SEARCH("-",A1)+1,LEN(A1)),RIGHT(A1,1))
Drag down.
In case the second assumption is wrong, and it always needs to be one just change ..RIGHT(A1,1) to ..1
You can try below formula. It will return first numbers after - if there are multiple - in cell.
=IF(ISERROR(SEARCH("-",A1)),1,TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",100)),100,100)))
Related
I have part numbers with dashs and numbers for organization purpose, and I was wondering if there's a way I could de-concatenate the string into nearby cells with a formula or two and not go through Data > Text to Columns. Any idea?
Here's a demo of a formula-based approach. The formulas will work in Excel.
https://docs.google.com/spreadsheets/d/1LXtKOsxzo1J2-D1e4e_QUqxUug191GHJ5exWSWcoS0s/edit?usp=sharing
It works like this:
A1 contains the string you want to break up, say 12424-22778-3432626-442-52523262.
B2 contains this formula: =FIND("-",$A1,1). This will find us the first occurrence of - in A1.
B3 contains this formula: =FIND("-",$A1,B1+1). This will find us the next occurrence of - in A1 (it starts looking for - from the position following what we found in B2.
B4... can be copied over from B3. If you copy the cell rather than the formula, the formula will automatically change the reference to B1 to C1 and up. In the example, it's copied over all the way to E1.
F1 contains =mid($A1,1,B1-1). This gets us the string from the first char to the B1-1th char, i.e.: start to first occurrence of -, but without the -.
G1 contains =mid($A1,B1+1,C1-B1-1). You can copy this over up to the second to last cell. The gets us the string from the previous - (+1, i.e. without the -) to the next - (-1, i.e. without the -).
J1 is the last cell and contains =mid($A1,$E1+1,len($A1)). It works the same as the previous formula, but goes up to the end of the string in A1.
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
I'm trying to extract a word from a sentence if it starts with one of the following letters.Dell** or Samsung** or Apple**. The position of the words may vary in the cell.
A1: Dell2622 Retail34792 Lenovo StoreQuantity4
A2: Retail9858 Qty8 Samsung783546 Android
A3: Retail21512 Apple3411 StoreQty15 Macintosh
I am trying to use the following formula to extract the Dell** or Samsung** or Apple** if it's present int the cell.
=MID(A1, SEARCH({"Dell","Samsung","Apple"},A1), SEARCH(" ",A1, SEARCH({"Dell","Samsung","Apple"},A1))- SEARCH({"Dell","Samsung","Apple"},A1))
It works for the cell A1, but everything else returns #VALUE!. I guess it doesn't recognize that i want it to check for either or and extract either or. The result I'm trying to achieve is:
A1: Dell2622
A2: Samsung783546
A3: Apple3411
Later on i may need to add more things to search for, so I'm trying to keep it easily modifiable. I guess since it finds the first instance, then it's just a matter of tweaking something to ensure that if it didn't find the first value it looks for second, etc.
Assuming you have a data setup similar to the picture below, with your strings in column A, the formula in column B, and the words to look for in column D:
The formula in cell B2 and copied down is:
=TRIM(LEFT(SUBSTITUTE(MID(A2,MIN(INDEX(SEARCH($D$2:$D$4,A2&$D$2:$D$4),)),255)," ",REPT(" ",255)),255))
And per your request to not use a range reference and instead have the list of words directly in the formula:
=TRIM(LEFT(SUBSTITUTE(MID(A3,MIN(INDEX(SEARCH({"Dell","Samsung","Apple"},A3&{"Dell","Samsung","Apple"}),)),255)," ",REPT(" ",255)),255))
How do I make a cell show some of the characters of another cell?
For example cell A1 shows 'abc12345' and I want cell A2 to show '123' (i.e. characters 4 to 6).
Thanks in advance!
= mid (A1, 4, 3) would return 123
where A1 is the cell with the text string.
4 is the initial location to start getting the string
3 is the length of the string you will get.
This is the simple solution.
This one looks for the first numeric value and gives anything before that, press ctrl+shift+enter to run.
=LEFT(A1,MIN(IFERROR((MID(A1,ROW(A1:A200),1)+0)*ROW(A1:A200),FALSE))-1)
Hope that helps.
Following is the which I am trying :
Let this number 6,123,456.33 in Cell A1,
Then in Cell B1 use this formula =TEXT(A1,"#,###,###.##"), will give you 6,123,456.33.
Then in Cell C1 use this formula = SUBSTITUTE(B1,",",".") ,will give you 6.123.456.33
Then in Cell D1 use this formula =","&RIGHT(H12,2), will give you ,33.
Then again come to Cell C1 Do text to columns or other options to remove the last digits with decimals and then concatenate result with Cell D1 shows the last three digits.
This tip will ends up in 6.123.456,33
But Problem is in point no. 5.
How should I remove .33 from cell C1?
TRUNC is not working on C1.
Any Suggestions ?
Seems like you don't mind having the result as text (and I can't seem to find a way to custom format it...) and as such, you can use the formula:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(A1,"#,###.00"),",","#"),".",","),"#",".")
There's a triple substitution, one to remove , for # (a dummy character), second to change . to ,, then last from the dummy # to ..
If A1 is always a 7 digit number with 2 decimals then you could use TEXT function like this:
=TEXT(A1*100,"0\.000\.000\,00")