T
TKM
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
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