Run-time error '9': Subscript out of range on Copy/Paste VBA?

dougmarkham

Active Member
Joined
Jul 19, 2016
Messages
252
Office Version
  1. 365
Platform
  1. Windows
Hi Folks,

I have this copy/paste VBA which copies a range from one workbook into another workbook.

Code:
Public Sub CopyPaste()
Workbooks("GenericGRNReport(Excel2010).xlsm").Sheets("GRN_Data").Range("$E$3:$F$5000").Copy Destination:=Workbooks("113LastNightStockManagementReportMACRO1.xltm").Sheets("Stock Management Lookup").Range("$A$3:$B$5000")
End Sub

The Sheet names and Workbook names are all correct. Is there something wrong with this code that would cause a Run-time error 9?

Kind regards,

Doug.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
.xltm

Should that be: .xlsm?

Hi Pat,

It's an macro-enabled excel Template file. When I double click on the file, it opens the file name plus an extra 1 on the end of it.
So the question might be: will that opened macro-enabled excel Template file still be an *.xltm file, or does it open as an *.xlsm file?

Kind regards,

Doug.
 
Upvote 0
Hi Pat,

It's an macro-enabled excel Template file. When I double click on the file, it opens the file name plus an extra 1 on the end of it.
So the question might be: will that opened macro-enabled excel Template file still be an *.xltm file, or does it open as an *.xlsm file?

Kind regards,

Doug.

So I've tried replacing the *.xltm file extension with *.xlsm, but the error message persists.
Any ideas?
 
Upvote 0
Doug

When you double click on a template workbook then a new workbook based on the template is created and it will normally have a name consisting of the template name, without the extension, followed by a number.
 
Upvote 0

Forum statistics

Threads
1,224,812
Messages
6,181,088
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top