Dynamically extract string in excel - excel

I have a column called 'cArticle' in excel, containing data in below format. I have a requirement to extract in another column the code that is in brackets. Ex- Z1A,F5C,etc
cArticle
Molecular Dispersion (Z1A)
Acrona Perse (F5C)
Leco Spers (HLP)
Cullar Dipters (LPP)
I have managed to get it partially working by using the below formula, but it still returns with values with the closing brackets. How can I modify it to get the desired results?
RIGHT(cArticle,4)
Thank you in advance!

If the string always ends with (XXX) and the content in the brackets is always 3 digit. You can also try:
=LEFT(RIGHT(cArticle,4),3)

If your code is always at the farthest right and is only 3 characters long, you can use formula as below
=SUBSTITUTE(RIGHT(cArticle,4),")","")
However if your code is not always at the farthest right and may be more or less than 3 characters than you can use formula below, which will work in all cases even if there is no code present
=IFERROR(MID(cArticle,FIND("(",cArticle)+1,FIND(")",cArticle)-FIND("(",cArticle)-1),"No Code")

Related

Result not correct when using if, left and search in excel

I am trying to extract the text to the right of a character pattern of form -201*-*- in excel (I also tried using Access, but the issue persists).
For example, in the text:
EP-005-FI6-2012-1-124-000000-1
I want to extract the number 124; the following formula works:
=LEFT(RIGHT(C1,SEARCH("-201*-*-",C1)+1),3)
124
However, when i apply the exact same formula to extract169 from the text below:
NAATS-MG-D6-2017-1-169-070000-1
The formula returns a completely different result:
=LEFT(RIGHT(C540495,SEARCH("-201*-*-",C540495)+1),3)
-16
The pattern is the same, but the results is completely differnt.
My dataset is too big to go row by row fixing the issue...
Seems to be a simple problem, but i can't get this working...
Any thoughts?
Thank you
Your RIGHT() is wrong. Use:
=LEFT(MID(C1,SEARCH("-201?-?-",C1)+8,9999),3)

Single Line to Double-line Formatting in Excel

In my job I have to enter warranty information so that POs can be cut. Vendors are very particular with how this is entered and each one has their own format.
One of them requires data be entered:
SN:
MACHTYPE:
Further, the information for this is sent in a single composite number, something like:
10Y754235FUYJ9
Requiring the final input of data to be:
SN:10Y75423
MACHTYPE:UYJ9
The first 4 digits of the composite are the MACHTYPE and the final 8 are the Serial Number.
The impasse I've reached is I can't seem to get auto-fill to replicate the skipping of lines as I've formatted. It will jump a number of lines equal to however many I've selected.
Any ideas about getting it to replicate the first four Formatted Data? I've been throwing myself at this for a couple hours now.
Thanks in advance!
I think you're over complicating it by using two rows for the Formatted Data. I'd wrap the text (Home tab > Alignment section) for the cells in column F and use the following formula to insert a new line:
=CONCATENATE("SN:",B1,CHAR(10),"MATCHTYPE:",C1)
Then just leave the formatting like you had it by row...
Okay, let's focus on the title. When A1 is 10Y754235FUYJ9,
="SN:"&LEFT(A1,8)&CHAR(10)&"MATCHTYPE:"&RIGHT(A1,4)
will give you the output:
SN:10Y75423
MATCHTYPE:UYJ9
And don't forget to set the wrap text checked at Format Cells menu.

Converting letters to text and back again (Excel 2013)

For a piece of coursework I have to complete a register of student grades. I am trying to calculate their overall grades by converting their grades from each of the four units into numbers (which I have done using the VLOOKUP function), but I need to then convert the result of the average back into a letter. I have used VLOOKUP and also a long nested IF statement to try and accomplish this, but no matter what I can never get a valid result. This is what I have so far (this is just a link to my image as I am unable to post one).
I have converted the Target grade into a number using the formula:
=VLOOKUP(D3,'Grade Values'!A$2:B$11,2,FALSE)
Then added up the total of the different grades from the four units using this formula:
=SUM(VLOOKUP(F3,'Grade Values'!A$1:B$11,2,FALSE)+
VLOOKUP(Dashboard!G3,'Grade Values'!A$1:B$11,2,FALSE)+
VLOOKUP(Dashboard!H3,'Grade Values'!A$1:B$11,2,FALSE)+
VLOOKUP(Dashboard!I3,'Grade Values'!A$1:B$11,2,FALSE))
And then averaged it out with this: =J3/4
The problem I am facing at the moment is that when converting this number back to a letter using the same table as in the second screenshot I get an N/A result when I use this formula: =VLOOKUP(K3,Dashboard!A1:B10,1,FALSE)
I can't seem to figure out what's going wrong with the formula at the end. If anyone can please help me figure this out I will appreciate it a lot. Thank you :)
Edit: I apologise for the irrelevant tags, as far as I was aware formulas in Excel were written in JavaScript.
Personally, I would convert the letter grade to ASCII character using the function:
CODE(A1)
use the ASCII Reference Chart for the integer value of each Upper Case character. Note: A=65, B=66, etc... Perform your calculations, then you can use the function:
CHAR(A2)
to convert the number back into a character.
Example:
A1="A"
A2="B"
A3="C"
B1="=CHAR(AVERAGE(CODE(A1),CODE(A2),CODE(A3)))"
just copy the column A in the sheet dashboard and paste it in column C in the sheet dashboard... so you have
A B C
A* 7 A*
A 7 A
B 6 B
....
the formula you have to use is
=VLOOKUP(K3,Dashboard!$B$1:$C$10,2,FALSE)
remember that this time u need to match a number... not a letter

How to modify numbers at the end of a cell using a formula

I have cells in excel containing data of the form v-1-2-1, v-1-2-10, v-1-2-100. I want to convert it to v-1-2-001, v-1-2-010,v-1-2-100. I have nearly 2000 entries
If all of the data follows the format shown then you could use FIND to return the position of '-'. There will be three instances of this character and you need to find the third one so use the position given by the first instance as the start position parameter of the second FIND and again for the third (essentially nesting FIND). Once you have the position of the third '-' you know where the final set of numbers are (from the returned third position+1 to the LEN of the string) and could use SUBSTITUTE or a combination of other excel string functions to configure the final portion as you need it.
I'm assuming that excel has your data formatted as text.
If you need further assistance I'm happy to knock up the formula in excel but I'm off to work now and won't be able to do so for around 9 hours.
Please try:
=LEFT(A1,6)&TEXT(MID(A1,7,10),"000")

Replacing a section of the data in a cell for thousands of excel data

I have a large spreadsheet with column data like:
ABC:1:I.0
ABC:1:I.1
ABC:1:I.2
ABC:1:I.3
ABC:2:I.0
ABC:2:I.1
ABC:2:I.2
ABC:2:I.3
ABC:3:I.0
ABC:3:I.2
ABC:3:I.3
ABC:4:I.0
ABC:4:I.1
ABC:4:I.2
ABC:4:I.3
ABC:5:I.0
ABC:5:I.1
ABC:5:I.2
ABC:5:I.3
ETC.
I need to replace the above with the following:
ABC:I.Data[1].0
ABC:I.Data[1].1
ABC:I.Data[1].2
ABC:I.Data[1].3
ABC:I.Data[2].0
ABC:I.Data[2].1
ABC:I.Data[2].2
ABC:I.Data[2].3
ABC:I.Data[3].0
ABC:I.Data[3].2
ABC:I.Data[3].3
ABC:I.Data[4].0
ABC:I.Data[4].1
ABC:I.Data[4].2
ABC:I.Data[4].3
ABC:I.Data[5].0
ABC:I.Data[5].1
ABC:I.Data[5].2
ABC:I.Data[5].3
ETC.
Here is a sample of the data, most of the data follows a similar format with the exception of the naming "ABC", which can vary in size, so it might be "ABCD" and also with the exception of the letter "I", it can be "O" as well. Also, some might be missing some values such as ABC:3:I.1 which is missing from the data. I am not too familiar with excel formulas or VBA code. Does anyone know how to do this? I have no preference on which method it has to be done in as I don't mind learning some VBA code if someone provides me with a VBA solution.
I was thinking of using some sort of loop along with some conditional statements.
Thanks!
Please try:
=LEFT(F11,FIND(":",F11))&MID(F11,FIND(":",F11,6)+1,1)&".Data["&MID(F11,FIND(":",F11,2)+1,1)&"]."&RIGHT(F11,1)
copied down to suit, assuming placed in Row11 and your data is in ColumnF starting in Row11.
Curiosities:
When this A was first posted it attempted to address only the tabulated example input and output. I temporarily deleted that version while addressing that what was in the table as ABC might at times be ABCD and that what was I might at times be O.
OP has posted an answer that I edited to make no visible change but which shows as the deletion of two characters. A copy of the OP’s formula exhibited a syntax error prior to my edit.
OP suggested an edit to my answer but this was rejected by the review process. As it happens, I think the edit suggestion was incorrect.
I have edited my answer again to include these ‘curiosities’ and to match the cell reference used by the OP in his answer.
=LEFT(A1,SEARCH(":",A1)) & MID(A1, SEARCH(".",A1)-1, 2) &
"Data[" & MID(A1,SEARCH(":",A1)+1,1) & "]" & RIGHT(A1,2)
With the help of pnuts I was able to come up with my own solution:
=LEFT(F11,LEN(F11)-5)&MID(F11,LEN(F11)-2,2)&"Data["&MID(F11,LEN(F11)-4,1)&"]"&RIGHT(F11,2)
My solution works based on the fact that the length of the last six values in the string ABC:1:I:0 will always be the same in size for all the data I have, hence you see LEN(F11)-some number in my code. The only part of the string that changes in size is the first part, in this case ABC which can also be ABCDEF, etc.
If you'd like to use formulas rather than VBA, an easy option is to split the data into 4 columns, using the Text To Columns option - first split using the colon as a delimiter, then using a full-stop / period as a delimiter.
Once you have 4 columns of data (one for each block), you can use the Concatenate function to join them and add in the extra characters: =CONCATENATE(A1,":",C1,".","Data[",B1,"].",D1)
This should still work if you have extra / alternative characters (eg ABCD instead of ABC), as long as you have the same delimiters, but obviously you'd need to test to make sure.

Resources