creating pdfs RRS feed

  • Question

  • Hi

    Requirement:Create multiple pdfs from single sheet:

    first pdf-data from column A,B and G

    Secoond- A,B,H

    and so on

    I am using below code, it is giving error during saving pdf code, please see:

    Sub looping()
    ' looping Macro
    Dim x As Integer
    Dim LastCol As Integer
    Dim LastRow As Integer

    With ActiveSheet
            LastCol = .Range("A1").SpecialCells(xlCellTypeLastCell).Column
        End With
         With ActiveSheet
         LastRow = .Range("A1").SpecialCells(xlCellTypeLastCell).Row
        End With
     Worksheets("Sheet1").Range("A1:B10").PasteSpecial Paste:=xlPasteValues

      For x = 7 To 9
        Range(Cells(6, x), Cells(10, x)).Copy
        Worksheets("Sheet1").Range("C5").PasteSpecial Paste:=xlPasteValues
        fName = Sheets("Sheet1").Range("x6").Value
        Sheets("Sheet1").ExportAsFixedFormat Type:=xlTypePDF, filename:= _
        "C:\Users\Chetna_\Desktop\Pdf data\ & fName,Quality:=xlQualityStandard,IncludeDocProperties:=False, IgnorePrintAreas:=False,OpenAfterPublish:=False"
        fName = Empty

     Next x
    End Sub

    Monday, February 19, 2018 3:57 PM

All replies

  • The quotes are placed incorrectly:

            Sheets("Sheet1").ExportAsFixedFormat Type:=xlTypePDF, _
                Filename:="C:\Users\Chetna_\Desktop\Pdf data\" & fName, _
                Quality:=xlQualityStandard, IncludeDocProperties:=False, _
                IgnorePrintAreas:=False, OpenAfterPublish:=False

    Regards, Hans Vogelaar (

    Monday, February 19, 2018 6:18 PM