Subscript out of range

E

Ed

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Closing workbook 4
Importing data 3
Import Wizard 1
If Problem 8
Copy - Paste 5
ERROR: subscript out of range 6
I need help with a "Run-Time Error 13: Type Mismatch" 2
Last row 1

Top