Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ed ed is offline
external usenet poster
 
Posts: 59
Default Subscript out of range

Hi

I have the following code which should copy values in a
sheet and then paste them into a new sheet but it comes up
with the error 'Subscript not in range'

Does anyone have any ideas why this is happening?

Thanks

Sub Import_Crystal()

Dim fname As String


ChDrive "S"
ChDir "S:\Kingston\FA\Overseas Payments\Overseas Payments
Public\Ed"
fname = Application.GetOpenFilename()

Workbooks.Open (fname)
Windows(fname).Activate
Sheets("TEST11").Select
Range("A1:AQ100").Select
Selection.Copy
Windows("Remittance Procedure").Activate
Sheets("Crystal_Table").Select
ActiveSheet.Paste
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Subscript out of range

Ed,

Is it this line

Windows(fname).Activate

If so, just delete it. It is unnecessary as the newly opened workbook
becomes the activeworkbook by default.

By the way, the erros is caused by the fact that fName is a full path name,
not just the workbook name.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ed" wrote in message
...
Hi

I have the following code which should copy values in a
sheet and then paste them into a new sheet but it comes up
with the error 'Subscript not in range'

Does anyone have any ideas why this is happening?

Thanks

Sub Import_Crystal()

Dim fname As String


ChDrive "S"
ChDir "S:\Kingston\FA\Overseas Payments\Overseas Payments
Public\Ed"
fname = Application.GetOpenFilename()

Workbooks.Open (fname)
Windows(fname).Activate
Sheets("TEST11").Select
Range("A1:AQ100").Select
Selection.Copy
Windows("Remittance Procedure").Activate
Sheets("Crystal_Table").Select
ActiveSheet.Paste
End Sub



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
Subscript out of range OKHM Excel Discussion (Misc queries) 0 August 6th 09 05:18 PM
Subscript out of Range Steve Excel Discussion (Misc queries) 3 April 15th 09 04:01 PM
9: Subscript out of range jenz21985 Excel Discussion (Misc queries) 6 May 5th 06 03:36 PM
SubScript Out Of Range. Sam Excel Programming 4 December 21st 03 02:10 AM
Subscript Out of Range John Wilson Excel Programming 2 September 7th 03 04:07 AM


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