View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
ksh ksh is offline
external usenet poster
 
Posts: 16
Default Run-time error 9 when trying to copy a worksheet

Thank you. It worked perfectly. I would never have been able to do this
without this group as a resource.

"Jim Thomlinson" wrote:

Sheets.count is referening to the active workbook and not thisworkbook. Give
this tweak a try...

with ThisWorkbook
Sheets("EQUIP-CR").Copy After:=.Sheets(.Sheets.Count)
end with

--
HTH...

Jim Thomlinson


"ksh" wrote:

The following code is part of a macro I have set up. The first two lines
(select "CR" and rename as "EQUIP-CR") work perfectly, but I get a run-time
error 9 (Subscript out of range) when it gets to the copy worksheet line.

Sheets("CR").Select
ActiveSheet.Name = "EQUIP-" & ActiveSheet.Name

Sheets("EQUIP-CR").Copy After:=ThisWorkbook.Sheets(Sheets.Count)

I'm sure it is something very simple, but my VBA skills are limited and I
haven't been able to figure this one out. Any help is appreciated.