2016-07-29 2 views
0

이 코드는 일반적으로 새 이름을 지정할 가능성이있는 시트를 저장하고 구멍 시트가 아닌 일부 열을 저장하기 위해 변경하려고했지만 코드는 나에게 오류를 표시합니다다른 시트에 열 저장

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 

답변

1

이 당신이 시도하고있는 무슨이다 : 1004, 하나는 당신을 감사하십시오이 나를 도울 수 이 내 코드? 사물의

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 

커플 ...

  1. 먼저 이름을 물어보세요. 사용자에 의해 주어진 이름이 대상을 지정하는 경우, 기존 시트
  2. 일치뿐만 아니라 범위를 지정하지 않는 경우
  3. 는 마 루프
  4. 확인을 사용하지 마십시오. 예를 들어 A1을 사용했습니다.
+0

고맙습니다. 정확히 내가 고맙습니다. – mateos

관련 문제