View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default read excel worksheet

[Sheet2$] is used to identify the "table"

disregard my code. You previously said nothing about querying a sheet.

--
Regards,
Tom Ogilvy

"NuB" <CSharpCoder wrote in message
...
will i be able to run a query against it like what you have below?
currently i'm just doing "select office , city, address from A1:C100" and
this gives me all the data within that range, but I only have 1 sheet in
there now. But the actual exel document i'll be using will have the 3.
So I need to query the frist sheet, the 2nd sheet and the 3rd sheet to get
different data and then combine them into one file.


"Tom Ogilvy" wrote in message
...
set rng = worksheets(2).Range("A1").CurrentRegion
set rng = rng.offset(1,0).Resize(rng.rows.count-1,1)
for each cell in rng
msgbox "Office: " & cell.Value & vbNewLine & _
"City: " & cell.offset(0,1).Value & vbNewLine & _
"Address: " & cell.offset(0,2).Value
Next

--
Regards,
Tom Ogilvy


"microsoft.news.com" <CSharpCoder wrote in message
...
I have an excel file with 3 worksheets that i'm using as a database.

How
can
I read a particular worksheet and get those values out of the cells?

Example:

Sheet1
Name State Address
John PA
Sally DE


Sheet2
Office City Address
Main Campus Philly
Select Baltimore

How can I get the values from Sheet2 only?