+ Reply to Thread
Results 1 to 2 of 2

Is It Possible To Get SQL To Execute Directly From An Excel Cell?

  1. #1
    Registered User
    Join Date
    08-23-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    1

    Question Is It Possible To Get SQL To Execute Directly From An Excel Cell?

    Hi there,

    Is it possible to get SQL to run directly from an Excel cell. What I mean is is it possible to say have a prewritten SQL statement in cell A1 that when the spreadsheet is opened or refreshed the values generated are entered into cell A2?

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    08-12-2010
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Is It Possible To Get SQL To Execute Directly From An Excel Cell?

    Quote Originally Posted by ScotExcel View Post
    Hi there,

    Is it possible to get SQL to run directly from an Excel cell. What I mean is is it possible to say have a prewritten SQL statement in cell A1 that when the spreadsheet is opened or refreshed the values generated are entered into cell A2?

    Thanks in advance.

    It's unbelievably possible. I'd need more details but I'll assume you've done nothing on it yet.

    For this code to work you'll need to add a reference to "Microsoft ActiveX Data Objects [2.8] Library" (in VBA go to Tools > References, find it, tick it). 2.8 is in my reference list, if it's not in yours just use another one.

    Please Login or Register  to view this content.

    You'll have to figure out those XXXXXXXXXs yourself. I'm not sure if you're using sql server or mysql etc. Google "connection string" for whatever you're using (e.g. "sql server connection string"). Obviously you'll have to know your username and password as well.

    I called the sheet "Data", you can change that to anything you want.

    You can call that function from wherever, e.g. when the workbook opens.
    (http://www.ozgrid.com/VBA/auto-run-macros.htm)

    Edit:
    More information on ADO, http://support.microsoft.com/kb/257819, http://msdn.microsoft.com/en-us/libr...2(SQL.80).aspx
    Last edited by ReportMaker; 08-24-2010 at 05:55 AM. Reason: More information

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1