Adam Lonsdale
Adam Lonsdale

Reputation: 37

Reading Excel numbered range with oleDb

I am trying to select everything in the B - E columns from row 4 onwards, where row 4 are the headers. My sheet name is " PRODUCTION_Insurer Index".

My research so far has hinted that because my sheet name has spaces in it, I need to wrap it in single quotes along with adding a $ onto the end, this lead me to the following SQL:

SELECT * FROM [' PRODUCTION_Insurer Index$'] which selects everything just fine. I am having trouble with actually selecting the range.

Furthermore, I researched on Ranges and figured that with names such as Sheet1, I could do SELECT * FROM [Sheet1$B4:E] or something similar to select a range

However the following SQLs all Fail with the error:

The Microsoft Jet database engine could not find the object '' PRODUCTION_Insurer Index$B4:E''. Make sure the object exists and that you spell its name and the path name correctly.

SELECT * FROM [' PRODUCTION_Insurer Index$B4:E']

SELECT * FROM [' PRODUCTION_Insurer Index$'B4:E]

SELECT * FROM [' PRODUCTION_Insurer Index'$B4:E]

SELECT * FROM [' PRODUCTION_Insurer Index$B4:E313']

SELECT * FROM [' PRODUCTION_Insurer Index$'B4:E313]

SELECT * FROM [' PRODUCTION_Insurer Index'$B4:E313]

Upvotes: 0

Views: 1345

Answers (1)

Ciarán
Ciarán

Reputation: 3057

Ohhh, close. Try...

 "Select * From [PRODUCTION_Insurer Index$B4:E313]"

Upvotes: 2

Related Questions