I have a working dynamic SQL in a VBA-macro. The only problem I'm having is how to insert the required number of rows. At the moment, if there is anything in the first row it needs, it inserts the entire table to the left (which I don't want). I'd rather it overwrite what is there. If nothing is in the first row, it creates the table and overwrites everything to do it. Is there a way to declare a row for the table that it will expand/diminish as needed? Basically, I want it to populate as a regular SQL database query outside of VBA.
Currently I have this to update the table:
Set oQt = ActiveSheet.QueryTables.Add( _
Connection:=sConn, _
Destination:=Range("a3"), _
Sql:=var1)
oQt.Refresh
Currently I have this to update the table:
Set oQt = ActiveSheet.QueryTables.Add( _
Connection:=sConn, _
Destination:=Range("a3"), _
Sql:=var1)
oQt.Refresh