Solved

Excel VBA  using SQL to join tables

Posted on 2013-11-19
4
421 Views
Last Modified: 2013-11-20
Hi

I have several tables that are dumped onto Excel spreadsheets
I know that creating a query by linking these tables would be
easy in a database, but is this achievable in Excel? In other words
can SQL be used within Excel?
0
Comment
Question by:murbro
  • 2
4 Comments
 
LVL 4

Expert Comment

by:SmittyPro
ID: 39661021
You can use PowerPivot.

HTH,
0
 

Author Comment

by:murbro
ID: 39661805
Thanks but I am trying to find something specifically in VBA
0
 
LVL 16

Accepted Solution

by:
Jerry Paladino earned 500 total points
ID: 39662122
Yes, use Microsoft Query that is embedded in Excel.   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.

HTH
Jerry
0
 

Author Closing Comment

by:murbro
ID: 39662215
thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
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 …

757 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

20 Experts available now in Live!

Get 1:1 Help Now