Excel VBA/Formula to search Column - excel

I need to search a column for 5-9 digit ID's that follow the term ^v_cusip= and are separated by commas. From first glance it seemed that the ID's were followed by ^v_sort_order so I tried:
=MID(A2,FIND("^v_cusip=",A2)+9,(FIND("^v_sort_order=",A2)-(FIND("^v_cusip=",A2)+9)))
However, what follows ^v_cusip= varies. Is there another formula or a VBA code I can use to search the rows? I cannot repeatedly use MID/FIND as there are thousands of rows with numerous variations of what can follow ^v_cusip=.
Thanks!

=LEFT(RIGHT(A2;LEN(A2)-FIND("^v_cusip=";A2)-8);FIND("^";RIGHT(A2;LEN(A2)-FIND("^v_cusip=";A2)-8))-1)
This will show only the part between ^v_cusip= and the next ^ character.
You can further split the string by comma.

What does the rest of cell details look like? Is there only '=' sign in each row? If so, perhaps you could do a text to columns and use the '=' sign as the delimiter.
Once it's split should put the ID in a predictable column.

Related

Extract Multiple Sub-strings Between Brackets/Parentheses in Excel

I have various strings (formatted as text) that have a similar syntax in column F. Eg:
1t ttn TEST FAILED (9-5 passOne, 21-7 & 877-12 passTwo)
I want to extract the numbers within the brackets into separate cells. There may be anywhere between 1 and 5 different numbers.
The numbers will always contain a dash (-) somewhere in the middle and may have up to 3 digits either side of the dash.
Is this possible? I've been through previous questions and can't find anything that answers this.
Edit to show entered JvdV formula:
With Excel 2016:
Formula in B1:
=SUBSTITUTE(FILTERXML("<t><s>`"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(REPLACE($A1,1,FIND("(",$A1),""),")",""),"&","&")," ","</s><s>`")&"</s></t>","//s[contains(., '-')][translate(., '`-','')*0=0]["&COLUMN(A1)&"]"),"`","")
Confirm through CtrlShiftEnter
Drag right, and down for all lines of data.
This assumed:
Substring of interest (between paranthesis) is always at the end.
Numbers with the hyphen as a delimiter may occur outside this substring and are not wanted in our results.
The trick here is to first sanitize the string and find the opening-paranthesis and remove everything prior to that using REPLACE(). Then, just SUBSTITUTE() the closing-paranthesis. The remainder can be split on spaces using FILTERXML(). To prevent errors and unwanted results I subsituted the ampersand and included accent graves to prevent Excel to recognize these substrings as dates. For more insight on the used xpath and the workings of FILTERXML() I'd like to refer you to this.

reformat excel text column to specific format

I have a column in my excel that includes authors name and it looks as follows:
My goal is to remove the dates + the last comma from all of these rows to make it something like this:
Is there a way I can do it in excel?
Based on your example, in which there are multiple commas in one cell, I would go with determining the position of the last comma first (in order to know where to slice the content of said cell). Then it's a matter of IF formula based on condition in which the last 4 characters in the cell are digits:
=IF(ISNUMBER(VALUE(RIGHT(A1,4))),LEFT(A1,FIND("#",SUBSTITUTE(A1,",","#",LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))-1),A1)
FYI: The "#" substitution is targeted at knowing exactly where the last comma occurs in the cell. Any other unique, not-appearing-in-the-string character would have done the same job.
I've tested the formula on below examples:

How to split using the last backslash character as delimiter in excel 2013?

We have a list with 1000's of values in a single column.The values will be in this format
W:\RT_QAQC\Received\20160411_GDM_QA\VD\RegRef\Afr\Geology\IAE_Geology_Africa_10M
W:\RT_QAQC\Received\20160411_GDM_QA\VD\GlobRef\Ind\GIS\SS_GIS_Ind
I would like to split it using the last backslash a delemiter. So the result will be
W:\RT_QAQC\Received\20160411_GDM_QA\VD\RegRef\Afr\Geology
W:\RT_QAQC\Received\20160411_GDM_QA\VD\GlobRef\Ind\GIS
And in the next column,
IAE_Geology_Africa_10M
SS_GIS_Ind
I've tried with this one
=TRIM(RIGHT(SUBSTITUTE(A1,"\",REPT(" ",LEN(A1))),LEN(A1)))
But it's only copying the characters after the last backslash
How about:
=MID(A1,1,FIND(CHAR(1),SUBSTITUTE(A1,"\",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))))-1)
This uses a simple technique to determine the position of the last occurrence of a substring in a string.
Another approach is to use tigeravatar's approach
Assuming your source data is in column A and you do not have a header row and your data start in row 1. In C1 use the formula you posted as it seems to do what you want for the second column. It also makes our life easIer on how to deal with the first column. In B1 place the following.
=LEFT(A1,LEN(A1)-LEN(C1)-1)
Results

Trim cells before comparison

I am using a formula to sum a certain word from a filtered list on another sheet. I have the following formula and example of the data I am looking for:
=SUMPRODUCT((SUBTOTAL(3,OFFSET('Data'!R1,1,0)))*('Outage'!R:R="Birds"))
So what this formula does is go to the 'Outage' sheet and read a filtered Column R and looks for rows that have the word "Birds" and sums the occurrence and finally outputs it to a cell.
The problem I am having is that the data in Column R can have extra spaces in between. So for example, "Birds" would be " Birds" or "[newline]Birds". I am getting the data from a HTML page so there can be extra spaces.
When Excel executes SUMPRODUCT, "[newline]Birds" does not equal "Birds" so it doesn't increment my count, which I need it to do. I have tried:
=SUMPRODUCT((SUBTOTAL(3,OFFSET('Data'!R1,1,0)))*(TRIM('Outage Data'!R:R)="Birds"))
But it is not working.
Any help would be appreciated. Thanks!
TRIM will only remove whitespace at the start and end of the cell data. You need to use CLEAN to remove non-printable characters.
It may be that you need to use both if your data has newline and spaces.
Office Ref - CLEAN
So in theory the following should work for you:
=SUMPRODUCT((SUBTOTAL(3,OFFSET('Data'!R1,1,0)))*(TRIM(CLEAN('Outage Data'!R:R))="Birds"))

Excel: Delete ALL to the right of the right of particular first "character"

I need to delete all text to the right of the first "|" in a group of cells.
I had been using this:
=IFERROR(RIGHT(input,LEN(input)-FIND("stack",input)+1),"")
to delete to the left of a specific character. I found this in a stackoverflow question.
I am not sure how to make it so it reads to find the FIRST specific character. I also am trying to delete to the right of, but I believe I can fix that myself.
Thanks in advance
Assuming by the first "|" in a group of cells you mean the leftmost pipe character in each cell of an array of cells then as #Aprillion suggests =LEFT(A1,FIND("|",A1)-1) seems a good approach (where A1 is the first element of the array and the formula is copied across/down as appropriate).
If the group is a column, an alternative could be to use Data > Data Tools – Text to Columns with Delimited and Other: |, then delete inserted columns as required.

Resources