Did the data get returned to the locations you wanted? Sometimes the data is
organized very well on returned queries. Do you want different formating, or
just add header rows and header columns. Maybe add A title to the table or
add formating like borders around the cells or use different fonts. Not sure
what you need.
"Jeff" wrote:
I'm returning data from a SQL stored procedure that has 2 inputs Date1 and
Date2 using the following VB code.
With ActiveSheet.QueryTables.Add(ConnectionString, Range("A1"))
.CommandText = "EXEC sp_date_range_to_oee_values Date1, Date2
.Name = "Query from Plater_SQL"
.FieldNames = True
.PreserveFormatting = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
It works ok but when I run it a second or third time it creates another data
set and concatenates it to the right of the previous extraction. I'm
selecting the destination cells and deleting the contents each time before
running the extraction to prevent the concantenation.
It's not very elegant and I'd like to make it better. Any thoughts.
Jefff