0

My code successfuly reads tabular data from a workseet with data starting from cell A1. A fragment of my code looks like this:

Myconnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                          "Data Source=" & Myworkbook & ";" & _
                          "Extended Properties=Excel 8.0;" & _
                          "Persist Security Info=False"

    'Build SQL Statement


    strSQL = "SELECT  a as kod, b as wartosc, [Descr] as opis_grupy FROM [TableA$] " & _

Where [TableA$] must be an worksheet "TableA" filled with data starting from cell A1.

Is it possible, is there a syntax, that would allow me to refer not to data in a workseet TableA but in an object Table with a name TableA (in MSExcell 2010 one can create with ctrl+t), formerly known as list (in MSExcel2003)?

EDIT: so far I am overcoming the problem by using this function to build a reference to a hard coded range from a reference to table:

Function getAddress()

    myAddress = Replace(Sheets("Sheet1").Range("Table1").address, "$", "")
    myAddress = "[Sheet1$" & myAddress & "]"

    getAddress = myAddress

End Function
Erik A
  • 31,639
  • 12
  • 42
  • 67
Jacek Kotowski
  • 620
  • 16
  • 49
  • Its similar to this other question (http://stackoverflow.com/questions/18030637/how-do-i-reference-tables-in-excel-vba) – Zegad Apr 09 '15 at 15:06
  • Thanks Zegad for indicating that. I have read the other question and realised I am looking, more precisely, for a reference to Excel Table object in an SQL string (ACE OLEDB) in VBA. The other question asks for a reference to Table Object in VBA. I corrected the title to reflect this difference. – Jacek Kotowski Apr 09 '15 at 20:30

0 Answers0