LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Querying sheet of unknown name

Using the Connection object's OpenSchema method:

Sub test()
Dim Con As Object
Dim rs As Object
Set Con = CreateObject("ADODB.Connection")
With Con
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Tempo\db.xls;" & _
"Extended Properties=Excel 8.0"
.Open
Set rs = .OpenSchema(20) ' adSchemaTables
End With
With rs
Do While Not .EOF
Debug.Print !TABLE_NAME
.MoveNext
Loop
.Close
End With
Con.Close
End Sub

--

ChaunceyMo wrote in message ...
Hi all,

I am importing excels into code via an adodb connection, but have run
into the problem of many of the excels not having standard sheet names
(ie- "import" instead of "Sheet1"). Is there a way to do a SELECT
query without knowing the name of the sheet? This is further
complicated by the workbooks potentially having two sheets rather than
just one, again with an unknown name.

A method that iterates through the sheets sequentially would be
terrific.

Thanks in advance,
Mo


---
Message posted from http://www.ExcelForum.com/

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Querying Worksheets thefonz37 Excel Worksheet Functions 5 March 25th 08 04:55 AM
A function that looks for a value on a sheet on unknown column or row Paul134 Excel Worksheet Functions 2 February 28th 06 09:07 PM
QUERYING ACCESS Drew Excel Discussion (Misc queries) 3 July 13th 05 07:25 AM
Querying an excel sheet Jay Excel Discussion (Misc queries) 0 January 12th 05 08:41 AM
Excel VBA - Multi sheet filtering/querying(?) & combo box woes Don Hansford Excel Programming 0 March 7th 04 07:13 AM


All times are GMT +1. The time now is 06:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"