2016-10-27 2 views
0

코드에 두 번째 루프를 추가해야합니다. 현재 "딜러"라는 이름의 시트에서 "B2"로 시작하여 목록의 각 항목에 대해 다른 PDF를 인쇄합니다.매크로에 루프를 추가하는 방법

두 번째 루프는 길어야 만합니다. 선. 그것은 별도의 워크 시트에, 언어의 목록을 가서 여러 lagnuages있는 각 PDF를 다시 인쇄해야합니다.

을 이것에 어떤 도움이 많이 주시면 감사하겠습니다. 다음과 같이 내 코드는 ....

Dim PathString As String 

Sub Print_************_2_ImpactValidationReport() 

Application.ScreenUpdating = False 

Sheets("Dealer").Select 
Range("B2").Select 


    While Not ActiveCell.Value = Empty 

    Sheets("ImpactValidationReport").Range("AO1").Value = ActiveCell.Value 
    Sheets("ImpactValidationReport").Select 
    'Call ChangeGraphAxis 
    Range("A4").Select 
    Sheets("ImpactValidationReport").Select 
    Application.StatusBar = "Executing - Please be patient..." 
    Call Print_To_File4(Sheets("ImpactValidationReport").Range("AO1").Value) 
    Application.StatusBar = False 
    Sheets("Dealer").Select 
    ActiveCell.Offset(1, 0).Select 

Wend 

Sheets("ImpactValidationReport").Select 
Application.ScreenUpdating = True 

Sheets("ImpactValidationReport").Select 
Range("A3").Select 

MsgBox "All Completed, Please check Files!" 

End Sub 


Function Print_To_File4(Dealer As String) 

'PathString = ***************************\Reporting\DistrictReports\2_ImpactValidationReport" & DealerGroup & ".pdf" 
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, PrintToFile:=True, PrToFileName:=PathString 

CurrentDir = ActiveWorkbook.Path 
Application.DisplayAlerts = False 

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ 
    CurrentDir & "\Reporting\DistrictReports\2_ImpactValidationReport\District_Action_Report_" & Dealer & "_2_ImpactValidationReport_" & Format(Now, "dd-mm-yy") _ 
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _ 
    :=False, OpenAfterPublish:=False 

Application.DisplayAlerts = True 

End Function 

답변

0

내가 이해한다면 다음 구조를 사용하는 것이 좋습니다. (ij을 사용하여 루프) :

i = 1 
While Not cells(i,1) = Empty 
    'check all items 
    j=1 
    while not sheets("language").cells(j,1) = Empty 
     'check all languages for the item 
     j=j+1 
    wend 

    i=i+1 
wend 
관련 문제