I incorporated your SQLAddin tool into my project so I could execute my own SQL statements in my VBA code. I setup a SQL statement in a string and then use:
Call SQLAddin.ExecuteSQL(target range, sql string , True)
And get perfect results. Trouble is it now take several minutes to open the workbook. Been trying to figure out why this is. I came across about a thousand connections that didn’t lead anywhere so I thought that was it. I deleted all these connections but it hasn’t helped. At this point I’m at a loss.
Anybody have any ideas?
Thanks in advance…..
Depends how many Query Tables you created. The more queries the slower the Worksheet can get. Make sure if you are not using some Query Tables to delete them (you can check the created ones in the Data ribbon tab) – both connections and unused Query Tables.
If you just want to refresh a Query – then just refresh it. Don’t recreate it.
If you want to process results of SQL Queries line by line maybe you want to use the VBA RecordSet. See example here.