我有这个代码,通常它会保存一张可能给它一个新名字的工作表,我试图改变它以保存一些列而不是孔板但是代码显示我的错误1004,可以任何一个帮助我有这个请谢谢 这是我的代码:
Sub save()
Worksheets("operations").Activate
Dim sName As String
Sheets("operations").Range("N1:Q6000").Copy Destination:=Sheets(Sheets.Count)
On Error Resume Next
Do
sName = InputBox("Enter name for the release")
If sName = "" Then
Application.DisplayAlerts = False
ActiveSheet.Delete
Exit Sub
End If
ActiveSheet.Name = sName
If ActiveSheet.Name = sName Then Exit Do
Beep
Loop
End Sub
答案 0 :(得分:1)
这是你在尝试的吗?
Sub save()
Dim sName As String
Dim ws As Worksheet
sName = InputBox("Enter name for the release")
If Not sName = "" Then
On Error Resume Next
Set ws = Sheets(sName)
On Error GoTo 0
If ws Is Nothing Then
Sheets.Add after:=Sheets(Sheets.Count)
Sheets("operations").Range("N1:Q6000").Copy Destination:=Sheets(Sheets.Count).Range("A1")
ActiveSheet.Name = sName
Else
Beep
End If
End If
End Sub
一些事情......
A1
为例。