Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel Formula to Find Part of String

Posted on 2010-11-11
10
Medium Priority
?
318 Views
Last Modified: 2012-05-10
Hello,

I have a rather large list of files that I've put into Excel, and I'm trying to narrow it down to only ones that I require.  Can anybody help me write a formula that will look for specific parts of text within the cell, for example any file that contains .COMP, .XML, etc.

All help is appreciated.
0
Comment
Question by:angus_young_acdc
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34110342
Any further info about potential structures of the candidate strings ... i.e.

=RIGHT(A1, LEN(A1) - FIND(".",A1))

Will return all text to the right of the first dot

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34110351
Sorry didn't finish that

Will return all text to the right of the first dot ... but you may require last dot, text up to subsequent space or a number of other possibilities so representative data samples and required responses will help.

Chris

 
0
 
LVL 16

Expert Comment

by:Wadski
ID: 34110353
=find(".COMP",A1,1) where A1 is the cell with the info in.

or

=find(".XML",A1,1)
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 15

Author Comment

by:angus_young_acdc
ID: 34110375
Hey chris_bottomley and Wadski, unfortunately the strings will be of differing lengths so I won't be able to do a RIGHT or LEFT.  I shall try using find and get back to you both.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 34110379
If you just want specific file extensions then try listing all of those in a cell range, e.g. D2:D10 [with the preceding dot, i.e. ".COMP" etc, then assuming you have file names in column A use this formula in B2 copied down to identify (as TRUE) the files you want
=ISNUMBER(LOOKUP(2^15,SEARCH(D$2:D$10,A2)))
regards, barry
0
 
LVL 15

Author Comment

by:angus_young_acdc
ID: 34110409
A quick update, I've tried using a Find but that appears to bring back the starting point of the string.  

As requested I shall explain more, I have a list of over 400K files with various different extentions, mixed in with this are file names that I just don't need (their ext will be .XML, .COMP, .FIN)  So I'm hoping to have a formula that will look for these values, and allow me to easily remove them from the list.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 34110424
See attached example of my suggestion. You can now filter by column B to see the data you want/ don't want
regards, barry

26607563.xls
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 2000 total points
ID: 34110454
...sorry, I didn't include the dots in the list as I said you should - it worked OK in my example without but, of course, if you don't include the dot you might get a "false match" with text elsewhere in the filename.
see revised version
barry

26607563v2.xls
0
 
LVL 16

Expert Comment

by:Wadski
ID: 34110530
If you do a nested FIND statement with all three filetypes in it then sort by the column with the find statement you can then delete the rows with a number in them - leaving only the rows without these extensions.

you may also need to use the UPPER() statement if you are going to use the find statement to avoid lowercase filetypes being missed.

0
 
LVL 15

Author Closing Comment

by:angus_young_acdc
ID: 34113717
Thats fantastic thank you very much.  I had a bit of trouble getting this working though, I had to re-write the formula a few times (all exactly the same) before it would work.... I just put that down to bad luck.

Thanks again!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question