Was curious if anyone could help out I for the life of me can't seem to get trends found on Killersports or Sportsdatabase to import into excel. This pretty much last piece of automating my spreadsheet so be nice to have it done. If to difficult not a huge ordeal. Know they offer to save your personal trends and after a few the charge you a small fee, while it would be time saving. I don't mind doing the copy and pasting of the text if I have to. I've tried the importing it via typical web query through excel which gives me just that its trying to load but never get the teams I've also tried using VBA. Admittedly not the greatest when comes to VBA but can typically do enough to get myself what I want. Thanks in advance.
Start Excel. Open a new workbook and then save it as SQLExtract.xls.
Start the Visual Basic Editor and select your VBA project.
On the Tools menu, click References.
Click to select the most recent version of the Microsoft ActiveX Data Objects Library check box.
Creating the connection
Insert a new module into the project.
Create a new Sub procedure called DataExtract.
Type or paste the following code:
' Create a connection object.Dim cnPubs As ADODB.ConnectionSet cnPubs = New ADODB.Connection' Provide the connection string.Dim strConn As String'Use the SQL Server OLE DB Provider.strConn = "PROVIDER=SQLOLEDB;"'Connect to the Pubs database on the local server.strConn = strConn & "DATA SOURCE=(local);INITIAL CATALOG=pubs;"'Use an integrated login.strConn = strConn & " INTEGRATED SECURITY=sspi;"'Now open the connection.cnPubs.Open strConn
Extracting the data
Type or paste the following code to extract your records:
' Create a recordset object.Dim rsPubs As ADODB.RecordsetSet rsPubs = New ADODB.RecordsetWith rsPubs ' Assign the Connection object. .ActiveConnection = cnPubs ' Extract the required records. .Open "SELECT * FROM Authors" ' Copy the records into cell A1 on Sheet1. Sheet1.Range("A1").CopyFromRecordset rsPubs ' Tidy up .CloseEnd WithcnPubs.CloseSet rsPubs = NothingSet cnPubs = Nothing
Verifying that the code works
Run the code.
Switch to Excel and look at Sheet1 in the workbook to view the data.