VBA

  • Thread starter Thread starter dipsy
  • Start date Start date
D

dipsy

I get error at the following line of my code:

Sheets("2004 (2)").Name = "2004Data"

I have sheet - 2004. I copied that sheet. So now in
Excel the copy is 2004(2). I want to rename it
to "2004Data".

The above code gives me a Run time error - 1004 -
Application defined or object defined error.

TIA for the help.
 
I have windows & office 2000 and it does not work.
-----Original Message-----
I just tested what you had and it worked fine on xp xl2002

--
Don Guillett
SalesAid Software
(e-mail address removed)



.
 
the reason it may not work is because you have a sheet
with this name already. and it cannot create 2 sheets with
the same name.

it worked for me on office 97,2000,xp, and 2003
 
I have Excel 2k and the code it´s OK.

Take a look if there´s a hide sheet called 2004Data or if the name the worksheet in VBA is OK. When you wrote the name you used 2004(2) and in the VBA sample : 2004 (2) (there´s a space between the year and the number of sheet)
 
Instead of referring to the name of the newly copied sheet, you could rely on
the fact that the copied sheet is now the activesheet.

worksheets("2004").copy after:=worksheets("2004")
activesheet.name = "2004Data"

But this won't help if the real problem is that you already have a 2004Data
there.
 

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

VBA Help 3
Save file as CSV - Comma Separated 2
#REF! help please 3
Excel Excel VBA (Saving as A CSV) 1
Range("cell").Select Problem 2
Run time error message???....Help!! 12
VBA error 6
Please help with selecting a range 7

Back
Top