How to Extract Data in a string in Excel - excel-formula

I have some data as aaa.4A.aa, 4A-AAA, AAA/4A, AA.a.4.A.AA in excel and I want to extract only 4A from all these strings in Excel.
I have tried with substitute and replace with find functions.
=IF(ISNUMBER(SEARCH("4a",A2)),"4A"
I want 4A from all the above mentioned string in excel. Help me with the formula.

=IF(NOT(ISERROR(SEARCH("4a",A2))),"4A","")

Related

Extract text from a string in excel

I want to extract the Test #. and the description that follows into two different columns side by side. Currently I have one long string. I want to break the string into two sets and extract only the needed information.
I have attached a screenshot to make it more clear. In the past I have used the MID function and FIND to extract text from strings, but since the strings here vary in length and content I'm not sure how to do this.
Thank you in advance!!
Formula for cell A9:
= LEFT(A2,FIND(".",A2)-1)
Formula for cell B9:
= MID(A2,FIND(". ",A2)+2,FIND(" .",A2)-FIND(". ",A2)-2)
Drag formulas down as far as necessary.

Excel Macro to format date

I have a column with some string value in excel file.
Col A
20131022082702
20131022082702
20131022082739
20131022082739
I want to convert each cell value in to date format e.g. YYYY/MM/DD HH:MM
20131022082702 // should be formatted as 2013/10/22 08:27
I was just wondering if is there any built in function we can use to format it using some kind of macro?
One approach I can think of is taking sub string and writing custom logic in macro. Any other work around for it will be much appreciated !
Thank you for your time.
If you use the TEXT worksheet function, you can format it to look like a date/time stamp, and Excel will convert it to a "real" value. You can then format it as you wish:
=--TEXT(A1,"0000\/00\/00 00\:00\:00")
EDIT: In VBA, one can use this line to do the conversion. Similar algorithm, but using native VBA functions:
cdate(format(N,"0000 00 00 00:00:00"))
where N is your 14 digit number
More long-winded than #Ron's answer but another method is separating the string out:
=TEXT(DATE(MID(A1,1,4),MID(A1,5,2),MID(A1,7,2))+TIME(MID(A1,9,2),MID(A1,11,2),MID(A1,13,2)),"dd/mm/yyyy hh:mm")

String formula with variables in same sheet

I'm relatively new to excel formulas so I don't know the best way to approach this, or word it to find a good answer through the search.
I have the following data:
I want to take the formula string that is contained in the E column for each row, replace variables with data that are in the same row and evaluate the expression. I have no idea if this is even possible, but I'm willing to try VB Macros or whatever is needed.
Using the above thinking:
B8 = SUM(4 + (8 / 2))
B9 = SUM(5 + (6 / 2))
C8 = SUM(5 + (6 / 2))
etc...
If this ISN'T possible, my real overarching goal here is to just have a single location for the formula. I will have much more than 3 columns of data so being able to update it in one location would be perfect for me. Any help is appreciated.
Used Defined Names and your formulas as they are actually written.
Select all rows with data starting from Column A
Then click on main tab Formulas\in the group Defined names click on Create from Selection
Then copy your formulas to the corresponding columns in row 8 and 9
Note that the defined names Created from selection are added at workbook level, and it may be an issue if there are other similar worksheets... This can be workout by creating the names at worksheet level, using the Define name option instead.
using the
I have tried to use a more dynamic solution, using a Vlookup to find the values to add together.
Here's how I have the data (Note the formula shown is old, see edit):
The first two answer blocks are (respectively):
=SUM(VLOOKUP("Az",$A$2:$D$6,column(),FALSE)+(VLOOKUP("Cx",$A$2:$D$6,column(),FALSE)/2))
=SUM(VLOOKUP("By",$A$2:$D$6,column(),FALSE)+(VLOOKUP("Ev",$A$2:$D$6,column(),FALSE)/VLOOKUP("Dw",$A$2:$D$6,column(),FALSE)))
...and drag over.
But I realize you're looking, in the end, to be able to perhaps more quickly edit the formula variables, so my second two answers (rows 11 and 12) use the column F, G, and H to look for the variable:
=SUM(VLOOKUP($F$11,$A$2:$D$6,COLUMN(),FALSE)+(VLOOKUP($G$11,$A$2:$D$6,COLUMN(),FALSE)/2))
and
=SUM(VLOOKUP($F$12,$A$2:$D$6,COLUMN(),FALSE)+(VLOOKUP($G$12,$A$2:$D$6,COLUMN(),FALSE)/VLOOKUP($H$12,$A$2:$D$6,COLUMN(),FALSE)))
Does that kind of get you where you wanted? I'm trying to think of a way using perhaps indirect() ro use E8 and E9 more directly, so if you edit that formulas, the others change too...
Edit - Here's the "best" solution, insofar as all you need to do is edit the variable names in E8 and E9 and the formula will update itself. (If you follow my layout above), in B8 use
=SUM(VLOOKUP(MID($E$8,SEARCH("(",$E$8)+1,2),$A$2:$D$6,COLUMN(),FALSE)+(VLOOKUP(MID($E$8,SEARCH("+(",$E$8)+2,2),$A$2:$D$6,COLUMN(),FALSE)/2))
and in B9,
=SUM(VLOOKUP(MID($E$9,SEARCH("(",$E$9)+1,2),$A$2:$D$6,COLUMN(),FALSE)+(VLOOKUP(MID($E$9,SEARCH("+(",$E$9)+2,2),$A$2:$D$6,COLUMN(),FALSE)/VLOOKUP(MID($E$9,SEARCH("/",$E$9)+1,2),$A$2:$D$6,COLUMN(),FALSE)))
That way, if you want to sum, say Sum(Cx+(Ev/2)) all you have to do is edit E8 to that formula, and the answer1 in B8 will update itself.

Finding changing text in Excel or Google Spreadsheet

hope you can help with an Excel or Google Spreadsheet question.
In one column I have different words, which I would like to search for in a certain area in the spreadshet. Fx. is B3 present from B50:B678 is B4 present from B50:B678 and so on. The text is not an exact match. That means that sometimes the searchwords is placed in the whole sentes. See this data for an excample: https://docs.google.com/spreadsheets/d/1MX8WsnwcxEety-sv2ttEcUqgAgEUbpUd_xD18cG20lk/edit#gid=574850130
Hope you can help. With no succes I have tried these formulas:
=ifError(filter($B$775:$B$7887,ifError(search(B4,$B$775:$B$7887),false)))
=IFERROR(IF(UNIQUE(FILTER(B776:B7888,B776:B7888=B3))="text","Found","Not Found"),"Not Found")
=search(B3,J3:J98)
But the formulas don´t work if there is no excact match...Hope you can help
Best regards
Kåre Kildall Rysgaard
Datajournalist, Analystik.dk
In Google Spreadsheet count the number of occurrences of your search string within the test range by embedding the test string within wildcard characters:
=if(countif(A$15:A$2100,ʺ*ʺ&A4&ʺ*ʺ)>0,ʺFoundʺ,ʺNot Foundʺ)
The answer in Excel is similar but note that double quotes in Excel use a different character to that in Google Spreadsheet:
=IF(COUNTIF(A$15:A$2100,"*"&A4&"*")>0,"Found","Not Found")
It appears that Google Spreadsheet uses ANSI 63 for double quotes while Excel uses ANSI 34.

Converting CSV data format

First time question here..
I have 100's of CSV files I need to convert using whatever means you think necessary.
The format is an ever-accumulating value e.g.
01/01/2012,96,1000,1100,1150,1200,1400,1450,......
02/01/2012,96,1900,2050,2060,......
But I need this in a single value format, so I need the difference between each value e.g.
01/01/2012,96,100,50,50,200,50......
02/01/2012,96,150,10,......
96 is the no. of values in each row.
Thats the 1st part, the next is to ignore any row which doesn't have 96 values,
so:
01/01/2012,1024,96,96.7,96.5,96.3,.....
would be ignored.
I'm very new to writing scripts/macros so baby steps please!
UNTESTED. I suggest:
Import a .csv to Excel.
Turn on Macro recorder.
Text to Columns with , as delimiter.
Filter column containing 96 to select any value other than 96 and delete those rows.
Add a row for the differences.
Concatenate the results of 96 columns with the likes of =A2&","&B2&","….
Adjust code to suit.

Resources