Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
oafdl
 
Posts: n/a
Default How can I Run a query from VB macro with out affect current data in the same sheet?


How can I Run a SQL query from a VB macro and retrieve the imported data
in a range of a sheet with out affect existing graphics and data?

This sheet has data and graphics in range "A1:M20". I want to keep it
there and the query table Destination property := Range("A50").

The query works fine, fill de query table in this range ("A50") but,
deletes the graphics and any data that was in the sheet before
executing the macro.


With ActiveSheet.QueryTables.Add(Connection:="ODBC;DSN= Excel Files; _

DBQ=D:\Weekly reports\WEEKLY06.xls;DefaultDir=D:\Weekly
reports", _
Destination:=Range("$A$50"))
.CommandText = SQLQuery1 & SQLQuery2
.Refresh BackgroundQuery:=False
End With


Thanks


--
oafdl
------------------------------------------------------------------------
oafdl's Profile: http://www.excelforum.com/member.php...o&userid=34908
View this thread: http://www.excelforum.com/showthread...hreadid=546532

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
Get External Data - not editable using Query Wizard MargaretBeckbury Excel Discussion (Misc queries) 7 January 17th 06 09:13 AM
AHHHH-Get Data from Multiple Excel workbooks JAA149 Excel Discussion (Misc queries) 5 October 30th 05 05:19 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
data from one sheet to several in sequential order! firecord New Users to Excel 6 June 22nd 05 05:10 PM
Returning data to Excel sheet from MS query SNB Excel Discussion (Misc queries) 0 April 27th 05 01:27 AM


All times are GMT +1. The time now is 01:26 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"