LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
O'C O'C is offline
external usenet poster
 
Posts: 4
Default Worksheet naming using visual basic

What I have is a work schedule based on a calendar setup. I currently use a
macro to automatically save the "schedule" worksheet by copying the worksheet
to a new sheet which renames it using the date from cell A2, i.e. "26 Oct -
15 Nov 2006".

The code looks like this:

Sheets("SCHEDULE").Copy AFTER:=Worksheets(Worksheets.Count)

Sheets("SCHEDULE (2)").Select
Cells.Select
Selection.Copy
Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("a1").Select

Sheets("SCHEDULE (2)").Name = Sheets("SCHEDULE (2)").Range("$a$2")

Sheets("INFO").Select
Calculate

Sheets("SCHEDULE").Select
Range("A1").Select

The problem I have is that when I make a mistake and/or correction and try
to save it again I get the old run time error 1004 saying that you can't
rename a sheet when I have that same existing name from the previous save.
When I stop the debugger it still copies it to "schedule (2)".

Here's what I want. I want it to either overwrite the same named file with
the new one or automatically name it with the date and the (2) symbol and so
on. I don't want the debugger to be tripped by an error.

I appreciate any help you can give me...

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual basic editor Answerfactory Excel Discussion (Misc queries) 3 October 9th 06 09:13 PM
Adding a dymanic formula to a cell using visual basic Ian Web Excel Discussion (Misc queries) 2 September 28th 06 09:59 PM
Adding a dymanic formula to a cell using visual basic Ian Web Excel Discussion (Misc queries) 0 September 28th 06 09:26 PM
Microsoft Visual Basic Error in Excel mack Excel Discussion (Misc queries) 0 August 24th 06 07:27 PM
Visual basic Check Box and the IF formula dingo33 Excel Discussion (Misc queries) 3 February 15th 06 04:57 PM


All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"