Solved

Search multiple lines

Posted on 2016-10-13
3
36 Views
Last Modified: 2016-10-17
Is it possible to search a cell for a particular line and put it in another cell.

For example
=findLine(A2,"Short Results:")

Open in new window


Where in A2 holds:-

SUMMARY
------------------------------------------------------------------
Short Results: Nothing to be done
Operation completed at 18:29:33 on 12/10/2016
Total duration: 00:29:30
------------------------------------------------------------------

And the result of the fomula will be:-
Nothing to be done

If there isnt then Ill make my own function in VBA, just thought Id ask
0
Comment
Question by:tonelm54
3 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41841839
Hi,

pls try
Function FindLine(rng As Range, strText As String) As String
For Each Ln In Split(rng.Value, Chr(10))
    If Trim(Ln) Like strText & "*" Then
        Res = Trim(Mid(Trim(Ln), Len(strText) + 1))
        Exit For
    End If
Next
FindLine = Res
End Function

Open in new window

Regards
0
 
LVL 23

Expert Comment

by:NBVC
ID: 41841847
Perhaps something like:

=TRIM(IF(ISNUMBER(FIND("Short Results:",A2)),MID(A2,LEN("Short Results:")+1,FIND(CHAR(10),A2)-LEN("Short Results:")),""))
1
 
LVL 23

Expert Comment

by:Danny Child
ID: 41843462
Do you just want to check a bunch of cells that contain multiple lines for the "Short Results:" text entry, and if found, display "Nothing to be done" ?

if so, try this:
=IF(FIND("Short Results:",A2)>0,"Nothing to be done","")
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

786 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