Using excel and modifying string based on search function - excel

I am trying to get a value or all values similar to below in excel:
#123 maybe some text and date 12/17/209
#048309 maybe some text and date 12/17/209
#9385 maybe some text and date 12/17/209
I want to get the value proceeding the # however, I am not sure if there is an easier function? I want it to find the # then get however many numbers proceeds it. I am familiar with regex not with excel functions unfortunately.
Sorry for vagueness:
I was trying to use an IF() supplying a # as the find operation for the character I just couldnt manage to get the number as I was trying to use RIGHT() to filter after the #. What I found with the RIGHT() function is that it expects a parameter for count and so would have to be dynamic so I dropped that idea.

This formula will get the numbers directly after #:
=--MID(A1,FIND("#",A1)+1,FIND(" ",A1,FIND("#",A1))-FIND("#",A1))

Related

Using FIND function in excel

I have a date "2017-09-01 00:02:01". I need to use the FIND function to identify the first space in this date. The following function gave me an error on MS-excel but worked perfectly fine on google sheets.
=FIND(" ",C2)
Why?
I tried to split the date and time in the above mentioned value. In order to do that, I wanted to use the RIGHT and LEFT functions. To use these functions, I needed to use the space as a delimiter and so I tried identifying the position at which the space is using FIND function.

extract certain text after certain characters

what is the easiest way with an Excel formula to extract certain details from a cell? So for example, if this is in cell A1 column=""HMI_LOCATE"" px=""CLASS"" position=""99"" validation=""ROOM"" then I'm trying to extract just the data the falls in between the double "" after the px= so in this example, I need to extract just the letters CLASS and nothing else, what is the easiest way to extract that data, the part I'm trying to extract won't always be 5 characters long it could be much longer or shorter.
Do you want to achieve this?
With o365 you can use this formula
=FILTERXML("<t><s>"&SUBSTITUTE(A1,CHAR(34)&CHAR(34),"</s><s>")&"</s></t>","//s[position() mod 2 = 0]")
or for older EXCEL-versions
=IFERROR(INDEX(FILTERXML("<t><s>"&SUBSTITUTE($A$1,CHAR(34)&CHAR(34),"</s><s>")&"</s></t>","//s"),ROW(A1)*2),"-")
This splits the string at the quotation marks (CHAR(34)) and builds an array of elements. Then every second element is put out.
For tons of other possibilities have a look at this awesome guide by JvdV.
EDIT:
To get the element after px= no matter where it is, you can use
=LET(list,
FILTERXML("<t><s>"&SUBSTITUTE($A$1,CHAR(34)&CHAR(34),"</s><s>")&"</s></t>","//s"),
INDEX(list,MATCH("px=",list,0)+1)
)
The LET-function lets you assign functions to variables which then can be used for further calculations.

How to extract unique values from an array EXCEPT specified values?

I am already abel to extract unique values, in excel, from an array using this function:
{=INDEX(list,MATCH(0,COUNTIF(uniques,list),0))}
However, I want to specify certain values for excel not to return. Is there any way to specify values that I don't want to be found within the already specified "list"? The ideal outome would be something like this:
I am also using excel version 2101.
Any information is helpful, thanks!
From your example, I ASSUME you want to exclude the lines starting with Round.
Try:
=LET(x,UNIQUE(List),FILTER(x,LEFT(x,5)<>"Round"))
or
=UNIQUE(FILTER(List,(LEFT(List,5)<>"Round")))
I'm not sure if it is more efficient to filter a smaller list, as is done in the first formula; or to avoid using LET as is done in the second formula.
EDIT
This can also be done using FILTERXML and TEXTJOIN which should be present in all Windows versions 2016+
=FILTERXML("<t><s>"&TEXTJOIN("</s><s>",,list)&"</s></t>","//s[not(starts-with(.,'Round')) and not(preceding-sibling::*=.)]")
the xPath
not(starts-with(.,'Round')) : should be obvious
Return only unique values:
and not(preceding-sibling::*=.) : do not return a node if any preceding-sibling matches the current node being tested

how to find the characters between 2 strings in excel

I have an xml file imported into excel with the tags. How do i retrieve the value of the string between 2 strings.
Eg. "<"product_offer_group_id">"686819743"<"/product_offer_group_id">"
How do i retrieve 686819743 from this. To note the string length is varying and ranges from 1 to 20 digits.
you need to procced in excel? Not sure about possibility of usage of regular expressions(which are a pretty good solution for that case) in Excel standard functions, but with VBA You can for sure.
look here:
http://lispy.wordpress.com/2008/10/17/using-regex-functions-in-excel/
Alternativelly you can also try to play with standard Excel Text functions, like find, left, right etc.
If you want a solution without using VB script and only Excel functions, assuming your value is in cell A1, the following use of MID, FIND, and CHAR functions would work:
=MID(A1,FIND(CHAR(34)&">"&CHAR(34),A1,1)+3,FIND(CHAR(34)&"<"&CHAR(34),A1,FIND(CHAR(34)&">"&CHAR(34),A1,1)+1)-FIND(CHAR(34)&">"&CHAR(34),A1,1)-3)
The above searches for the first occurrence of the tag ">", and takes whatever is between that tag and the next occurring "<" tag.
The magic number 3 in the function is the length of these two searched tags and used to cut down on calling an additional LEN(CHAR(34)&">"&CHAR(34)) function.

How to parse cells and remove selected data from excel

I have this as a few cells in excel 2010:
(source: gyazo.com)
There are a few things I am trying to accomplish, though they're really all variations of the same thing.
In both Price Paid and Price Returned, I have values that can either be formatted as "# (type)" or as an expression of the form "# (type)+# (type2) ...". What I'm trying to do is reduce the expressions from their current state into just numerical values. I've figured out how to do it if it is just the first case ("# (type)"), however I'm having issues with doing the second case, since the parse stops after the first instance of " ". Below I have the code that I'm using in both Numerical Paid and Numerical Returned. The ISNUMBER category is there just to show which things register as numbers and which don't.
Numerical Paid and Numerical Returned Code:
=INT(IF(ISNUMBER(D2),D2,LEFT(D2,FIND(" ",D2,1)-1)))
I did some more google searching and found that someone had already written a VBA function to do this. Lovely.
I've linked the source below.
http://www.vbusers.com/code/codeget.asp?ThreadID=624&PostID=1
All I had to do was replace the ".," with "+-/*", so that it'll handle all operations. Simple, elegant, and useful. Afterwards, I used the solution posted here (as an answer to another one of my questions):
How to make a cell equal to the value of an expression in another cell (Excel 2010)?
to evaluate the resulting string.
Thanks everyone.

Resources