Select to Excel

This small Excel macro allows you to execute SQL commands on any ODBC data source directly in Excel and will paste the results in an Excel sheet where you can sort, filter and further manipulate the data. Useful to quickly extract data from a database and manipulate it within excel. No need to copy and paste large sets of data from other programs to gain the full functionality of Excel.

Some ODBC databases do not have convenient SQL query tools. For example, I work with Transact ODBC (U/SQL) every day and their query tool does not allow you to copy results and paste it into Excel. I often need to extract some data for a client and email it to them in Excel. In the past I used to change a generic PHP page to give me the results in an HTML table, which I could copy into Excel. This works, until you need to extract a couple of hundred or thousand rows, in which case it takes a couple of minutes just to copy the HTML table into memory. With this macro, the results are immediately available in Excel.

There's nothing fancy about this macro and it will only be useful to people who are comfortable with SQL and probably have the skills to develop something like this themselves. This is why I am giving it away for free and why the source code is available to you to alter as you wish. My experience though, is that if I find something useful, there will be other people who'd also find it useful in their own day-to-day lives. Have a look at it. If you can use it, go ahead - otherwise, nothing lost.

Download now

Select your ODBC data source at the top-left. On the right is a list of all tables within that database and when you click on a table, all columns within that table are displayed for quick reference. Type your SELECT statement in the SQL Statement box and click Execute. The resultset from the SELECT statement will be output to an Excel worksheet where you can play around with the data or save it to a seperate sheet, which you can email to a client as I do.