Solved

Search multiple lines

Posted on 2016-10-13
3
30 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 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
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
Comment Utility
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:DanCh99
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now