jeudi 25 août 2016

Add VBA Conditional Statement to Loop

So I have this code below that currently works. All of the data is on a tab called "Table" and feed into a tab called "Att A" that gets produced into 100+ pdf files and named based on the value that is in column A in the "Table" tab.

I would like to add a conditional statement to the following code that checks the value in column CH in the "Table" tab and if it is greater than 0 save in one location, if it equals 0 then save in another location. Since there are 100+ lines of data, the value in column A needs to check the value in the same row for column CH.

So the logic goes to column A (Uses this value as the file name), creates a file, and checks column CH to determine which folder to save the file in. How do I add this condition to the following code?

Sub Generate_PDF_Files()
    Application.ScreenUpdating = False
    Sheets("Table").Activate
    Range("A7").Activate

    Do Until ActiveCell.Value = "STOP"
        X = ActiveCell.Value
        Range("DLR_NUM") = "'" & X

        Sheets("Att A").Select
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "L:\Mike89\Sales" & X & ".pdf", Quality:=xlQualityStandard, _IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

        Sheets("Table").Activate
        ActiveCell.Offset(1, 0).Activate
    Loop
End Sub

Aucun commentaire:

Enregistrer un commentaire