hello experts,
I used this macro for a long time in many excel files , now all of a sudden , it stopped working and after I click the button it gives path/file access error (with a changin .tmp file name every time) and then after I click ok it gives another error runtime error 2147352565 (8002000b) - can't copy this sheet
and all of this happened out of the blue, 100/100 on the desperate meter , is there any clue for what the problem is ?
Essentially the code copy-paste a template sheet and renaming it to the inputbox the user've entered.
Sheets(strName).Select near the end of the code in this line is where I get the yellow mark of error
thanks for any help ,
Netanel
I used this macro for a long time in many excel files , now all of a sudden , it stopped working and after I click the button it gives path/file access error (with a changin .tmp file name every time) and then after I click ok it gives another error runtime error 2147352565 (8002000b) - can't copy this sheet
and all of this happened out of the blue, 100/100 on the desperate meter , is there any clue for what the problem is ?
Essentially the code copy-paste a template sheet and renaming it to the inputbox the user've entered.
Sheets(strName).Select near the end of the code in this line is where I get the yellow mark of error
thanks for any help ,
Netanel
VBA Code:
Option Explicit
Private Sub CommandButton1_Click()
Dim ws As Excel.Worksheet
Dim strName As String
On Error GoTo ErrHandler
strName = Application.InputBox("Please enter the description...", "New Item", Type:=2)
If strName <> vbNullString Then
strName = ValidSheetName(strName)
Else
MsgBox "Cancelled...", vbInformation
Exit Sub
End If
If SheetExists(strName) Then
MsgBox "You already have a description called " & strName, vbExclamation, "Error"
Exit Sub
End If
'// Turn off screen updating...
Application.ScreenUpdating = False
With Sheets("template")
.Visible = xlSheetVisible
.Copy after:=Sheets(Sheets.Count)
End With
Set ws = ActiveSheet
With ws
.Name = strName
.Visible = xlSheetVisible
.Range("StrategyName").Value = strName
End With
'// Add a row to the TOC table
Dim oNewRow As ListRow
Set oNewRow = ListObjects("StrategyTOC").ListRows.Add(AlwaysInsert:=True)
With oNewRow
.Range.Cells(1, 2).Value = strName
End With
ErrHandler:
Sheets("sheet for Contents").Activate
Application.ScreenUpdating = True
Sheets(strName).Select 'in this line I get the yellow mark of error
End Sub