#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro Help

Following is my macro that copies a hidden sheet
(extended reservation) and renames the sheet as the value
in cell C4 on Create Reservation sheet. If C4 is an
existing sheet name the macro returns an error and the new
sheet is named extended reseervatiom(2). I would like, if
there is a duplicate, for extended reservation(2) not to
be created. Also how do I assign short cutkey to the
macro.

Sorry so long and Thanks!!!
'
' create Macro
' Macro recorded 8/21/2003 by zz535a1
'
'

Sheets("EXTENDED RESERVATION").Visible = True
Sheets("EXTENDED RESERVATION").Copy After:=Sheets(2)
Range("C1:C7").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("B9:B104").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlFormulas,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True
Sheets("EXTENDED RESERVATION").Select
ActiveWindow.SelectedSheets.Visible = False

Call Worksheet_Change


End Sub

Private Sub Worksheet_Change()
Dim sName As String

sName = CStr(Sheets("CREATE RESERVATION").Range
("C4").Formula)
Sheets("EXTENDED RESERVATION (2)").Name = sName

End Sub

..


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Macro Help

Private Sub Worksheet_Change()
Dim sName As String
Dim ws as worksheet

sName = CStr(Sheets("CREATE RESERVATION").Range
("C4").Formula)

For Each ws In ActiveWorkbook.Worksheets
if ws.Name=sName
exit sub
end if
Next


Sheets("EXTENDED RESERVATION (2)").Name = sName

End Sub

..


-----Original Message-----
Following is my macro that copies a hidden sheet
(extended reservation) and renames the sheet as the value
in cell C4 on Create Reservation sheet. If C4 is an
existing sheet name the macro returns an error and the

new
sheet is named extended reseervatiom(2). I would like,

if
there is a duplicate, for extended reservation(2) not to
be created. Also how do I assign short cutkey to the
macro.

Sorry so long and Thanks!!!
'
' create Macro
' Macro recorded 8/21/2003 by zz535a1
'
'

Sheets("EXTENDED RESERVATION").Visible = True
Sheets("EXTENDED RESERVATION").Copy After:=Sheets(2)
Range("C1:C7").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("B9:B104").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlFormulas,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True
Sheets("EXTENDED RESERVATION").Select
ActiveWindow.SelectedSheets.Visible = False

Call Worksheet_Change


End Sub

Private Sub Worksheet_Change()
Dim sName As String

sName = CStr(Sheets("CREATE RESERVATION").Range
("C4").Formula)
Sheets("EXTENDED RESERVATION (2)").Name = sName

End Sub

..


.

Reply
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


All times are GMT +1. The time now is 07:29 AM.

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

About Us

"It's about Microsoft Excel"