2014-02-11 2 views
0

아무도 나를 도울 수 있는지 궁금합니다. 나는 직원으로 지명 된 장을 선정하고 그들이 일하는 곳에 의존하는 정확한 학습서로 그 (것)들을 끼워 넣는 매크로가있다.과거의 VBA 오류 선택하기

나는 저장소를위한 모든 시트를 선택하여 새로운 통합 문서로 복사하도록 매크로를 만들었습니다.

내 문제는 해당 위치 통합 문서를 모두 건너 뛰는 시트 중 하나를 찾을 수없는 경우입니다. 다음 위치로 이동합니다. 이 방법은 둥근 방법인가요? 매크로가 시트 중 하나를 찾을 수 없다면 나머지 시트를 움직입니다. 사람들이 항상 ALL 기타 사항 서보 -OFF 사용 먼저이 프로그램을 느리게 .activate, 둘째, 데는 보통, 당신도/활성화 선택할 필요가 없습니다해야하는 이유

Sub BIR() 
    On Error GoTo Getout 
    Sheets(Array("Martyn Arthur Lewis", "Norman Stewart Gray")).Move 
    Sheets.Select 
    For Each ws In Worksheets 
     ws.Activate 
     With ActiveSheet.PageSetup 
      .PrintHeadings = False 
      .PrintGridlines = False 
      .PrintComments = xlPrintNoComments 
      .Orientation = xlLandscape 
      .Draft = False 
      .PaperSize = xlPaperA4 
      .FirstPageNumber = xlAutomatic 
      .Order = xlDownThenOver 
      .BlackAndWhite = False 
      .Zoom = 90 
      .printerrors = xlPrintErrorsBlank 
      .OddAndEvenPagesHeaderFooter = False 
      .DifferentFirstPageHeaderFooter = False 
      .ScaleWithDocHeaderFooter = True 
      .AlignMarginsHeaderFooter = False 
     End With 
    Next 
    ChDir "\\afi-uplift\documents\company\Support Services\Support Services Level 1\Reports\Transport Reports\Vehicle KPI" 
    ActiveWorkbook.SaveAs Filename:="\\afi-uplift\documents\company\Support Services\Support Services Level 2\Support Services\Transport\Drivers\Driver Performance\BIR Driver KPI " & Format(Date, "yyyy.mm.dd") & ".xlsx" _ 
    , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False 
      Windows("Driver Report.xlsm").Activate 
    Getout: 
End Sub 
+0

이 몇 가지 코드 : 게시 – Belial09

+0

코드를 게시하시기 바랍니다, 감사 –

+0

을 당신이 무엇을 달성하고자하는 약간 불분명하다 :이처럼 작성하는 경우

은 당신의 코드가 작동하지 않습니다. 코드가 예상대로 작동하지 않는 부분을 명확히 할 수 있습니까? – Johanness

답변

0

이해가 안 돼요.

option explicit 'forces user to dim variables, , alot easier to find errors 

err.clear 
on error goto 0 'how can you debug errors with a on error goto (or on error resume next) ? 

dim ws as worksheet  

For Each ws In Sheets(Array("Martyn Arthur Lewis", "Norman Stewart Gray")) 
    With ws.PageSetup 
     'your code 
    end with 
next ws