2

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Link no longer active

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.