In Excel VBA, I am using Excel as datasource for some queries. I am using the query as
SQL = "Select * from [NameRange1]" - This works
But, I want to use a table name instead of Namerange(Excel 2007 Tables). How do I use that? I tried "select * from [Table1]"
and I also tried creating a Namerange for this table1 and it didn't work either..
any ideas please?
You don't say whether you're using DAO or ADO to connect, but I don't think it matters. I don't think it's possible to refer to a Table. All the documentation I've seen lists three types of ranges: an entire sheet [Sheet1$], a named range[NameRange1], or an unnamed range [Sheet1$A1:B10].
I am able to give an Excel 2010 table a named range that includes the header and that works just like any other named range, and it changes size with the addition of rows. Make sure that if it's a sheet-level named range you do it like [Sheet1$NameRange1].
The best information I found on doing it with ADO is here: http://www.xtremevbtalk.com/showthread.php?t=217783
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.