Solved

Query table in excel, filter by date

Posted on 2014-01-18
7
1,182 Views
Last Modified: 2014-01-21
I have a table of projects in Excel.  There is a column for Project Name and and column for End Date.  I would like a query in a separate worksheet that returns a column of data containing only those Project Names that end prior to a date I enter into a cell in Excel.  Suggestions for best way?

So far:
Pivot Table - does not have filter for less than arbitrary date.

Control Array - returns only filtered projects but leaves blank lines where projects do not match criteria.  I do not want blank lines.

VBA code - yes, I could build my own filter easily enough, but prefer existing tools if possible.  This may end up as best solution.

query builder - not friendly to finding tables in existing workbook.  I would like to be proven wrong about this.
0
Comment
Question by:RolandGarton
7 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 39790927
I could help in VBA if and when you feel ready have a file posted first.
gowflow
0
 
LVL 16

Accepted Solution

by:
Jerry Paladino earned 175 total points
ID: 39792097
If your data is in a List / Table format then MS-Query is a simple solution.   In Excel 2007-2013 - Data menu, Get External Data, From Other Sources, "From Microsoft Query".   This uses ODBC to make a connection to the Excel files.   In the Choose Data Source dialog, select Excel Files*.   Select the workbook in the next dialog and then select the Worksheet in the "Add Tables" dialog.   There is an "Options..." button on the Add Tables dialog.  Make sure "System Tables" is checked or the available worksheets in the workbook will not display.

Use the ADD button to select one or more worksheets.   From there you have the ability to join tables and write SQL.   The user interface provides some drag and drop but don't expect MS-Access like capabilities.  

Screen shots below and the attached PDF show the steps to build a query and add the Parameter for selecting the date to show your projects.   The PDF is for a query to MS-Access but the steps are the same and the document is more detailed than the screenshots below.

HTH
Jerry
Project ListChoose data sourceSelect WorkbookAdd TablesQuery GridProperties dialogPropertiesParametersResult SetParameter-Query-with-Excel.pdf
0
 
LVL 32

Assisted Solution

by:Rob Henson
Rob Henson earned 25 total points
ID: 39796888
Have you looked at the Advanced Filter function?

This can extract data for specific columns that match specific criteria. This can be on a separate worksheet in the same workbook or can filter the data in place.

Thanks
Rob H
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Closing Comment

by:RolandGarton
ID: 39797235
Jerry - very helpful, thanks much.  I appreciate the examples.  I'm glad to know about the parametric option for queries--will be useful in other applications.  Problem, though: Once I created a new query, I then wanted to edit the query.  When I right-click/Table/Edit query I get the "connecting to data source..." box I'm used to, but this box does not eventually yield to Microsoft Query.  Instead, it hangs Excel and I have to use Task Manager to exit.  Do you know how I can edit the query after I've set it up?

Rob H - Thanks for the pointer.  Advanced Filter with copy elsewhere is an option I didn't know about.  It's a one-time deal that doesn't automatically update, so not as robust as Jerry's solution.
0
 
LVL 16

Expert Comment

by:Jerry Paladino
ID: 39798850
Roland,

Go to "Connection Properties" dialog box, which is the screen shot third from the bottom that I posted above.   To the left of the Parameters button is the Edit Query button.   That will take you back to the MS-Query screens.  Once you are comfortable with the SQL syntax you can edit the SQL that you see in the "Command Text" box on that same dialog if you want to.   Or, continue to use the drag and drop capabilities within MS-Query.

Use the "Refresh" dropdown on the Data Ribbon to get to the Connection Properties dialog box as shown below:Connection Properties
0
 

Author Comment

by:RolandGarton
ID: 39798965
Same problem.  I get the Connecting to data source dialog, and Excel hangs, to be stopped only through the Task Manager.

Connecting message
0
 
LVL 16

Expert Comment

by:Jerry Paladino
ID: 39798992
Roland,

Not sure since it works fine on both of my laptops.  May I suggest that you use two separate files as a place to start troubleshooting.   Have your complete list of projects in one workbook and setup the Query in second workbook.   That may avoid the connection issues you are experiencing.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.Range Set 25 77
Excel VBA get Access table names with ADO 2 21
Excel error  #DIV/0! 7 18
Copying from excel I am getting extra text 11 42
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

773 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