It's my fault Harry for not explaining better. There are some utility routines I reused from your previous post, that I included in the download file, but were not included in the cut and paste code above.
Make sure you backup your file.
Please make sure that none of the following routines are duplicated in your file or Excel may lock up when you attempt to open the file after saving.
The following routines should be in module ModCloneSheet2 in the download file in post #4 in this thread. You can get them from the file or cut and paste from below:
Sub LjmCreateCellBorder(myRange As Range, myRGBColor As Long, iBorderThickness As Long)
'This creates a Continuous Thick Cell border around each cell in a range
Dim r As Range
For Each r In myRange
With r.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = iBorderThickness
If myRGBColor = xlAutomatic Or myRGBColor = xlNone Then
.ColorIndex = myRGBColor
Else
.Color = myRGBColor
End If
End With
With r.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = iBorderThickness
If myRGBColor = xlAutomatic Or myRGBColor = xlNone Then
.ColorIndex = myRGBColor
Else
.Color = myRGBColor
End If
End With
With r.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = iBorderThickness
If myRGBColor = xlAutomatic Or myRGBColor = xlNone Then
.ColorIndex = myRGBColor
Else
.Color = myRGBColor
End If
End With
With r.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = iBorderThickness
If myRGBColor = xlAutomatic Or myRGBColor = xlNone Then
.ColorIndex = myRGBColor
Else
.Color = myRGBColor
End If
End With
Next r
End Sub
Public Function LjmSheetExists(SheetName As String) As Boolean
'Return value TRUE if sheet exists
On Error Resume Next
If Sheets(SheetName) Is Nothing Then
LjmSheetExists = False
Else
LjmSheetExists = True
End If
On Error GoTo 0
End Function
Function DoesSheetNameContainIllegalCharacters(sNewSheetName As String) As Boolean
'This returns 'True' if the Input 'Sheet Name' contains illegal characters
'Illegal Characters include: : \ / ? * [ ]
If InStr(sNewSheetName, ":") > 0 Then DoesSheetNameContainIllegalCharacters = True
If InStr(sNewSheetName, "\") > 0 Then DoesSheetNameContainIllegalCharacters = True
If InStr(sNewSheetName, "/") > 0 Then DoesSheetNameContainIllegalCharacters = True
If InStr(sNewSheetName, "?") > 0 Then DoesSheetNameContainIllegalCharacters = True
If InStr(sNewSheetName, "*") > 0 Then DoesSheetNameContainIllegalCharacters = True
If InStr(sNewSheetName, "[") > 0 Then DoesSheetNameContainIllegalCharacters = True
If InStr(sNewSheetName, "]") > 0 Then DoesSheetNameContainIllegalCharacters = True
End Function
Please let me know if you have any more problems.
Bookmarks