Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help with simple syntax error

What's wrong with the following???? I get "run-time error '9': Subscript
out of range" on the last line

Sub copyfinaldata()
Dim finalreportfile As String

'Open the FINALREPORT file

finalreportfile = InputBox("Open the final report", "Enter filename",
ThisWorkbook.Path & "\test.xls")
Workbooks.Open Filename:=finalreportfile


Windows(finalreportfile).Activate



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default need help with simple syntax error

add this
DIM WB as Workbook

then change this
Workbooks.Open Filename:=finalreportfile

to
SET WB = Workbooks.Open(finalreportfile)

to don't need to activate the workbook normally as the
newly opened book is usually the active one
however

WB.Activate

this methos gives greater control
eg
WB.Close False
to close without saving

HTH
Patrick Molloy
Microsoft Excel MVP







-----Original Message-----
What's wrong with the following???? I get "run-time

error '9': Subscript
out of range" on the last line

Sub copyfinaldata()
Dim finalreportfile As String

'Open the FINALREPORT file

finalreportfile = InputBox("Open the final

report", "Enter filename",
ThisWorkbook.Path & "\test.xls")
Workbooks.Open Filename:=finalreportfile


Windows(finalreportfile).Activate



.

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
Syntax Error In Date Beth Excel Discussion (Misc queries) 2 March 11th 09 01:05 PM
Syntax error Neil Pearce Excel Discussion (Misc queries) 4 November 21st 08 04:55 PM
syntax error - help Jim May Excel Discussion (Misc queries) 2 August 23rd 07 09:08 PM
question about syntax in a simple macro... Dave F Excel Discussion (Misc queries) 3 November 3rd 06 02:12 PM
Vlookup Syntax Error YV New Users to Excel 9 December 23rd 04 05:28 PM


All times are GMT +1. The time now is 04:02 PM.

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"