Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default VB Script for Excel Revised Question

I need to activate a workbook through a cell reference. the workook
name is stored in cell A1 as "pnlreport_060321.xls". This name
automatically changes daily based on the date. This is how I wrote the
code to activate the workbook:
Sub import()

Dim fileA As String
fileA = Range("A1").Value
windows("fileA").Activate

End Sub

However this does not seem to work. It gives me an error message
"Run-Time Error '9': Subscript Out of Range" and stops at the third
line (windows("fileA").Activate).

Please HELP. How would I activate a workbook which is already open. I
cannot use the file name in the code because the name changes every
day.

Thanks : )

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default VB Script for Excel Revised Question

Try

WorkBooks.Open (FileA)

in place of

Windows("FileA").Activate

No quotes around (FileA)

Nick

"VB Script for Excel" wrote:

I need to activate a workbook through a cell reference. the workook
name is stored in cell A1 as "pnlreport_060321.xls". This name
automatically changes daily based on the date. This is how I wrote the
code to activate the workbook:
Sub import()

Dim fileA As String
fileA = Range("A1").Value
windows("fileA").Activate

End Sub

However this does not seem to work. It gives me an error message
"Run-Time Error '9': Subscript Out of Range" and stops at the third
line (windows("fileA").Activate).

Please HELP. How would I activate a workbook which is already open. I
cannot use the file name in the code because the name changes every
day.

Thanks : )


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
VB Script for Excel Revised Question VB Script for Excel Excel Programming 3 March 23rd 06 03:33 AM
Revised formula question Sharon D. Excel Discussion (Misc queries) 11 December 25th 05 05:20 PM
Format excel to revised date automatically when revised annetteberrios Excel Programming 0 September 2nd 05 02:25 PM
IF Function with Date revised question taxmom Excel Worksheet Functions 5 February 8th 05 09:40 PM
Revised Question on Page Numbering Brady Snow Excel Programming 0 October 28th 03 04:34 PM


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