Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Newbie question on accessing data in xls

I have a series of manipulations in VBA.
I need to run this on data which is in ms-excel files I receive daily.
These files have multiple sheets (of different names) but the VBA applies to
them all the same.

How can I have the VBA access the cells in another ms-excel file?

I tried for example:
Worksheets(SheetName).Rows(1).Cells(1).Value

where I'd haveopen both teh xls files (one with data and the other with the
code),
and set the SheetName to the name of the target sheet.

But I get a "subscript out of range" error, which probably means the
sheetName was not found.

What is the best way of reading or accessing data on other xls sheets ?

Thanks in adv.
Tim




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Newbie question on accessing data in xls

I hope you'll forgive the question but in your VBA code
example you did not put the sheetname in quotes. Did you
put the sheetname in quotes?

Marty


-----Original Message-----
I have a series of manipulations in VBA.
I need to run this on data which is in ms-excel files I

receive daily.
These files have multiple sheets (of different names)

but the VBA applies to
them all the same.

How can I have the VBA access the cells in another ms-

excel file?

I tried for example:
Worksheets(SheetName).Rows(1).Cells(1).Value

where I'd haveopen both teh xls files (one with data and

the other with the
code),
and set the SheetName to the name of the target sheet.

But I get a "subscript out of range" error, which

probably means the
sheetName was not found.

What is the best way of reading or accessing data on

other xls sheets ?

Thanks in adv.
Tim




.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Newbie question on accessing data in xls

Hi Ernesto -

Using Worksheets(SheetName) assumes that the worksheet is within the
currently-active workbook. If you're working with macros in one Excel file
(aka workbook), and data in another, you'll have to specify the workbook as
well as the worksheet:

Try:

Workbooks("DataSpreadsheet.xls").Worksheets(SheetN ame).Cells(1,1).Value


"Ernesto" wrote in message
...
I have a series of manipulations in VBA.
I need to run this on data which is in ms-excel files I receive daily.
These files have multiple sheets (of different names) but the VBA applies

to
them all the same.

How can I have the VBA access the cells in another ms-excel file?

I tried for example:
Worksheets(SheetName).Rows(1).Cells(1).Value

where I'd haveopen both teh xls files (one with data and the other with

the
code),
and set the SheetName to the name of the target sheet.

But I get a "subscript out of range" error, which probably means the
sheetName was not found.

What is the best way of reading or accessing data on other xls sheets ?

Thanks in adv.
Tim






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Newbie question on accessing data in xls

Thanks that trick worked.


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
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Newbie question Pulling data from one sheet to another based on Tony Canevaro New Users to Excel 16 October 25th 05 02:10 PM
Newbie question: Matching data/2 wkshts copying info over dperry11273 Excel Worksheet Functions 2 July 26th 05 06:39 AM
Newbie Question: Data/Sort [email protected] New Users to Excel 1 February 21st 05 11:37 PM
Newbie to charts question - projecting values between data points 38N90W Excel Discussion (Misc queries) 3 January 6th 05 05:15 AM


All times are GMT +1. The time now is 01:10 AM.

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

About Us

"It's about Microsoft Excel"