我收到了
运行时错误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