Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default read excel worksheet

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?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default read excel worksheet

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?





  #3   Report Post  
Posted to microsoft.public.excel.programming
NuB NuB is offline
external usenet poster
 
Posts: 9
Default read excel worksheet

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?







  #4   Report Post  
Posted to microsoft.public.excel.programming
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?









Reply
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
How do I print worksheet, that is read only? bj Excel Discussion (Misc queries) 0 November 29th 06 02:32 PM
How do I print worksheet, that is read only? Newbe Excel Discussion (Misc queries) 0 November 29th 06 11:43 AM
Read worksheet in excel Kaustav Excel Worksheet Functions 0 November 11th 06 01:33 PM
How to read Excel worksheet with Excel Reader Stamo Excel Discussion (Misc queries) 0 March 14th 06 01:00 AM
Can I set up a worksheet as read only for one user Classic Excel Programming 1 December 7th 04 04:18 PM


All times are GMT +1. The time now is 01:15 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"