Error when moving sheet

  • Thread starter Thread starter mihai
  • Start date Start date
M

mihai

Hi

I have this code for moving a sheet:

Workbooks.Open Filename:=a & "situatie_qsar.xls"
Workbooks.Open Filename:=a & "situatie_qsar_z.xls"
Sheets("situatie_qsar_z").Move
After:=Workbooks("situatie_qsar.xls").Sheets(1)

At the thired line I recive this error:
Run time error 9: Subscript out of range

Why?
The two files are exported from a program in "Microsoft Excel 2.1
Worksheet" format and I'm using Excel 2000.
 
Subscript out of range in this case probably means that the sheet
'situatie_qsar_z' doesn't exist.
 
Hi

place the After line on the same line as the .Move command e.g.
Workbooks.Open Filename:=a & "situatie_qsar.xls"
Workbooks.Open Filename:=a & "situatie_qsar_z.xls"
Sheets("situatie_qsar_z").Move
After:=Workbooks("situatie_qsar.xls").Sheets(1)

Cheers
JulieD
 

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

Back
Top