I have an Excel list with course names and their number like this:
V3 Varikosis Masterclass
B3 Botulinumtoxin Premiumkurs, H2
M1 Mykologie Basiskurs [Digital], D1 Dermatoskopie Basiskurs [Digital]
B5 BTX Workshop (21.11.21) (sometimes there are random numbers that have nothing to do with the code like a date)
It's very messy since some people ordered two courses, so I can't just take the first two symbols from each cell. Is there a formula that finds and extracts a single letter and number combination from a string of text?
CodePudding user response:
If you do not have any other cases e.g. max number of courses is 2 and comma and space is always the same it is rather straightforward.
=LEFT(A3,2)
=IFERROR(MID(A3,SEARCH(",",A3,1) 2,2),"")
CodePudding user response:
You could try:
Formula in B1
:
=TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s[string-length()=2][translate(.,'ABCDEFGHIJKLMNIOPQRSTUVWXYZ','')*0=0][substring(., 2)*0=0]"))
What this does is:
FILTERXML()
- Use this function to break down you input into an array of elements based on the space characters as delimiter, where we would use Xpath 1.0 expressions to filter out;[string-length()=2]
- Nodes of exactly two characters;[string-length(translate(.,'ABCDEFGHIJKLMNIOPQRSTUVWXYZ',''))=1]
- Nodes where uppercase alpha is translated to nothing we are left with a single character;[substring(., 2)*0=0]
- Finally we just need to make sure the 2nd character of the node is numeric.TRANSPOSE()
- With ms365 the above will return an array which I transposed in columns. However, even with Excel2013 and above there is a way to find these seperate nodes.