• We are receiving reports of members using the private messaging service (Conversations) in ways that break the forum rules:
    • Do not invite another member to take the question off the forum (i.e. do not suggest that they post to a different forum, do not suggest that they email or private message you the problem, do not simply post a link to another forum, unless it is to a specific, relevant, thread). This applies equally to members asking or answering questions.
    • Soliciting business for yourself is not permitted. This is an all volunteer board, so offering solutions in exchange for compensation is not permitted. Likewise, members seeking solutions must not offer compensation for them. If you have an urgent need, check the Consulting Services page.
    Please help us out by clicking the Report link on any messages you receive that violate these rules. Thank you
  • If you would like to post, please check out the MrExcel Message Board FAQ and click here to register.
    If you forgot your password, you can reset your password.

Keep rows containing specified text strings


Active Member
Feb 17, 2002
Apologies if this is a "newb" question, but Power Query is completely new to me and I've no idea how to go about this...

I have a text file which is data dump from our email client and contains almost a million rows, most of which I don't actually need for the report I'm creating. The data is a single column for each record and looks something like this (anonymised):
ACL check OK, connection accepted from peer <123.4.567.89>
Message from: [abcd.efg@companyone.com]
Message to: [joe.bloggs@companytwo.com]
..Scanning decoded file. HH01_18_08_00_08_27.jpg


What I need to do is to only pull through rows which contain the text strings "message to" or "message from"

I'm using Excel as part of the Microsoft Office Professional 2013 Suite and have downloaded and installed the Power Query AddIn from Microsoft.

I've created the basic query by linking to the text file, but it's bringing through all records rather than just those containing "message to" or "message from"

Any suggestions as to how to do this would be gratefully appreciated!


Active Member
Feb 17, 2002
Panic over, I've found how to do it!

Edit Query, and THEN click the filter box in the top right and apply whatever parameters are required for your filtering. Microsoft could have made that a bit more obvious to find, although having now found it, it seems obvious with hindsight.

I had been trying to filter the data that had been brought through instead of filtering beforehand. I'd also played around with Parameters, but that wasn't what I needed in this instance.

I've managed to go from 798,000 records in total to the 168,000 that I actually need. I can then further manipulate those records with VBA merging them with data from other sources to generate my final report. I may ultimately be able to do everythign in Power Query, but this will work for now until I've learned more about the feature.

Forum statistics

Latest member
Raviteja KOTHA

Some videos you may like

This Week's Hot Topics