Activesheet.Name抛出内存不足错误

时间:2018-01-15 19:44:34

标签: excel vba excel-vba

我收到了

  

运行时错误7,内存不足

Activesheet.Name = strName行 strName是有效的工作表名称(没有特殊字符)。 我可以手动重命名工作表,没有任何问题。

Sub MakeNewCompany(sht As String)
'---------------------------------------------------------------------------------------
' Procedure : MakeNewCompany
' Author    : Kevin Waddle
' Purpose   : Make a copy of the Master Sheet named for the company
'---------------------------------------------------------------------------------------
'
Dim strName                         As String

strName = Replace(sht, " ", "")
If SheetExists(Replace(sht, " ", "")) Then
    MsgBox "There is already a sheet created for " & sht, vbCritical + vbOKOnly, "Already got some..."
Else
    Sheets("Master").Visible = True
    Sheets("Master").Select
    Sheets("Master").Copy After:=Sheets(ActiveWorkbook.Sheets.Count)
    ActiveSheet.Name = strName
    ActiveSheet.Range("A1").Value = sht
    Sheets("Master").Visible = False
End If 
End Sub

0 个答案:

没有答案