how to pass a list of SQL Server tables into List Box in Excel and use it -


i have made report file in excel analysts check data every morning. how looks now: enter image description here

where button's script following:

  sub button6_click()      dim qt querytable      sqlstring1 = "select * dbo.reportunits order productid, countrycodeid"      activesheet.querytables.add(connection:=getconnectionstr2, destination:=range("a3"), sql:=sqlstring1)             end  end sub  private function getconnectionstr2() 'driver={sql server}; getconnectionstr2 = "odbc;driver={sql server};" & _                    "database=em_countryconsumer;" & _                    "server=555.555.55.15;" & _                    "uid=user;" & _                    "pwd=password;" end function 

what have additional list box list of report tables in sql server database. in example dbo.reportunits table, there more report tables , creating automatically every day.

to give analysts chance choose table name. , show data pressing refresh button.

is possible? thank in advance!

  • create reference "microsoft activex data objects xxx library"
  • use adodb.connection , adodb.recordset objects create connection , define query on information_schema.tables
  • read column table_name items of (activex) listbox placed in sheet or listbox of vba form using .movenext , eof

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -