Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default Coping a Worksheet - but Getting an Error

I'm trying to use the following code to select a worksheet from one opened
file to another(filename 'fName' is passed to the sub function):


FileList = Application _
.GetOpenFilename( _
FilterIndex:=1, _
Title:="Open File That Contains Anderson
List")




Workbooks.Open Filename:=FileList
Sheets("Anderson List").Select
ActiveSheet.Copy After:=Workbooks(fName).Sheets
End Sub

But I'm getting a subscript out of range error. Any ideas why?

--
Thanks!
Max
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Coping a Worksheet - but Getting an Error

It seems that you're missing the sheet of which the copy should be placed
after. However, that causes a different error. Make sure the fName is set
appropriately. After you get the error, hover your mouse pointer over fName
and see if it displays the correct file name. Also, make sure that file is
open.

Good Luck,
Paul

"Max" wrote in message
...
I'm trying to use the following code to select a worksheet from one opened
file to another(filename 'fName' is passed to the sub function):


FileList = Application _
.GetOpenFilename( _
FilterIndex:=1, _
Title:="Open File That Contains
Anderson
List")




Workbooks.Open Filename:=FileList
Sheets("Anderson List").Select
ActiveSheet.Copy After:=Workbooks(fName).Sheets
End Sub

But I'm getting a subscript out of range error. Any ideas why?

--
Thanks!
Max



  #3   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default Coping a Worksheet - but Getting an Error

I would also recommend testing to see if the worksheet "Anderson List" exists
before trying to select it.

Not sure what is included in fName, if it is a full path and not just the
name of the file, that may be an issue, also the fact that .xls is on the end
of the filename may be a problem if it is there?

Just an idea....


"PCLIVE" wrote:

It seems that you're missing the sheet of which the copy should be placed
after. However, that causes a different error. Make sure the fName is set
appropriately. After you get the error, hover your mouse pointer over fName
and see if it displays the correct file name. Also, make sure that file is
open.

Good Luck,
Paul

"Max" wrote in message
...
I'm trying to use the following code to select a worksheet from one opened
file to another(filename 'fName' is passed to the sub function):


FileList = Application _
.GetOpenFilename( _
FilterIndex:=1, _
Title:="Open File That Contains
Anderson
List")




Workbooks.Open Filename:=FileList
Sheets("Anderson List").Select
ActiveSheet.Copy After:=Workbooks(fName).Sheets
End Sub

But I'm getting a subscript out of range error. Any ideas why?

--
Thanks!
Max




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
Retain Format When Coping Visible Cells Only to New Worksheet Ronster Excel Programming 5 January 12th 06 09:19 PM
Looking to copy a worksheet with all formats and formulas without coping inputed data God's Kid Excel Discussion (Misc queries) 3 October 28th 05 11:59 PM
Macro for coping cells from one worksheet to another ShahAFFS Excel Programming 3 August 31st 05 11:28 AM
coping ben kiser New Users to Excel 1 April 11th 05 01:41 PM
Error 50290: Error writing to Worksheet while using an ActiveX Control emblair3 Excel Programming 3 February 24th 04 06:03 PM


All times are GMT +1. The time now is 02:00 AM.

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"