Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Query run automatic update


in the dev environment (ALT+F11), from the Tools/References menu, choose
Microsoft ActiveX Data Object Library

then paste this code into a module (Insert/Module) - change as required

Public Sub FetchData()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim filename As String
Dim sql As String

filename = "c:\databases\test_Database.xls"
sql = "SELECT * FROM Blah"

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & filename & ";" & _
"Extended Properties=""Excel 8.0;"""

Set rs = New ADODB.Recordset
rs.Open sql, cn, adOpenKeyset, adLockOptimistic

Range("A1").CopyFromRecordset rs

'cleanup
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

"Kanmi" wrote in message
...
Please can anybody help me with scripts that i can use to run query update
from another workbook or worksheet that is when i right click and click on
REFRESH DATA then it will automatically run update from another workbook.
Please if you know any scripts that can do this function please advice.
Thanks and appreciate your time.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Update links to web query Alfredo_CPA Excel Programming 6 September 17th 08 09:02 PM
Automatic update of spreadsheet & automatic update between workboo Losva Excel Worksheet Functions 6 September 12th 08 03:22 PM
Automatic update through Web query mrbalaje Excel Discussion (Misc queries) 1 August 31st 07 08:09 PM
Enable Automatic Update for Web Query Terri Excel Worksheet Functions 0 May 5th 05 11:56 PM
Enable Automatic Update for Web Query Terri Excel Worksheet Functions 0 May 5th 05 11:56 PM


All times are GMT +1. The time now is 07:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"