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 |
All times are GMT +1. The time now is 06:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com