LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
TKM TKM is offline
external usenet poster
 
Posts: 33
Default Renaming wrong worksheet. Why?

I noticed this code is naming the wrong worksheet.. It assumes the newest
sheet is the one to be renamed and keeps renaming "sheet3". Any help
appreciated.

Public Function CopySheetAnalyst(xlSheet As Worksheet, Index) As Worksheet
'
' Macro2 Macro
' Macro recorded 7/11/2003 by SILVESC
'
Dim xName As String
Dim Basename As String
Dim x As Long

Call xlSheet.Copy(After:=Sheets(Sheets.Count))
Basename = Worksheets("CoverSheet").Range("B5").Offset(0, Index).Value
xName = Basename
On Error GoTo TryAgain
Sheets(Sheets.Count).Name = xName
On Error GoTo 0
Set CopySheetAnalyst = Sheets(Sheets.Count)
Exit Function
TryAgain:
x = x + 1
xName = Basename & "-" & x
Resume
End Function
 
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
Worksheet renaming jwilliam33 Excel Discussion (Misc queries) 5 December 6th 08 09:14 PM
Worksheet Renaming Eric Excel Discussion (Misc queries) 2 July 26th 07 02:44 PM
Worksheet Renaming Eric Excel Worksheet Functions 1 July 26th 07 02:38 PM
need help renaming a worksheet jonwyn Excel Discussion (Misc queries) 2 March 1st 05 08:34 PM
Renaming the Worksheet through VBA abxy[_24_] Excel Programming 4 February 9th 04 07:32 PM


All times are GMT +1. The time now is 06:34 PM.

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"