+ Reply to Thread
Results 1 to 5 of 5

Macros to export filtered PDF from log

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-12-2015
    Location
    Dubai,UAE
    MS-Off Ver
    Office 365
    Posts
    447

    Macros to export filtered PDF from log

    Hi,

    I have attached a small version of the logs we use.It has hundreds of entries with revisions.Every week I have to filter this list and submit to management according to some criteria.



    When I use Filter option, I have problem because Im not getting heading and title rows in Rows 2 and 4 to appear


    Im trying to automate this process.
    So im trying to get 3 buttons with assigned macros for printing and saving the PDF version to same folder for :

    1. Full Log Entries
    2. Filtered with items "LATEST" only in Column I
    3. Filtered with items "LATEST" and "LATE" in I and J respectively

    In all the PDFs,the heading and title row should also be printed.



    Thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Macros to export filtered PDF from log

    Hi chullan88

    Let me see if I understand correctly.....Do you want the following result....
    1. A Full version to be saved to pdf in folder and printed...
    2. a version with "LATEST" Filtered to be saved and printed
    2. a version with 2 filters "LATEST" & "LATE" Filtered to be saved and printed
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    07-12-2015
    Location
    Dubai,UAE
    MS-Off Ver
    Office 365
    Posts
    447

    Re: Macros to export filtered PDF from log

    Hi sintek,

    Yes thats what Im trying to achieve with three buttons assigned macros
    All three versions will be PDF in same folder
    The title row and heading should be there in all three

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Macros to export filtered PDF from log

    Have a look at attached... I have put it all in one button as it is not necessary for 3 buttons.

    Option Explicit
    
    Sub PDF_Filter()
    Dim lRow As Long, i As Long
    Dim ws As Worksheet
    Dim CritArr As Variant
    Application.ScreenUpdating = False
    Set ws = Sheets("Civil log")
    lRow = ws.Cells(Rows.Count, "J").End(xlUp).Row
    CritArr = Array("LATEST", "LATE")
    With ws
        '..................First Button Function
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:="Full Version" _
                        , Quality:=xlQualityStandard, IncludeDocProperties:=True, _
                        IgnorePrintAreas:=False, OpenAfterPublish:=False
        .PrintPreview 'change to .PrintOut
        For i = LBound(CritArr) To UBound(CritArr)
            .AutoFilterMode = False
            With .Range("A4:J" & lRow)
                If i = 0 Then
                    '..................Second Button Function
                    .AutoFilter Field:=9, Criteria1:=CritArr(i)
                    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=CritArr(i) & " Filtered" _
                        , Quality:=xlQualityStandard, IncludeDocProperties:=True, _
                        IgnorePrintAreas:=False, OpenAfterPublish:=False
                Else
                    '..................Third Button Function
                    .AutoFilter Field:=9, Criteria1:=CritArr(i - 1)
                    .AutoFilter Field:=10, Criteria1:=CritArr(i)
                    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=CritArr(i - 1) & "&" & CritArr(i) & " Filtered" _
                        , Quality:=xlQualityStandard, IncludeDocProperties:=True, _
                        IgnorePrintAreas:=False, OpenAfterPublish:=False
                End If
            End With
            '..................Second & Third Button Function
            .PrintPreview 'change to .PrintOut
        Next i
        .AutoFilterMode = False
    End With
    Application.ScreenUpdating = True
    End Sub
    Last edited by Sintek; 07-10-2017 at 05:39 AM.

  5. #5
    Forum Contributor
    Join Date
    07-12-2015
    Location
    Dubai,UAE
    MS-Off Ver
    Office 365
    Posts
    447

    Re: Macros to export filtered PDF from log

    Many thanks Sintek..

    It'll take some time to understand this code..

    Will get back to you after I get a hold..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Excel VBA Export filtered data to xls
    By moomphas in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-08-2016, 06:35 AM
  2. Export filtered data into different closed workbook as new worksheet
    By Griffin29 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2014, 06:24 AM
  3. Edit Macro to export filtered data into separate worksheet instead of PDF
    By tkowon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2014, 11:23 AM
  4. export filtered data (including header row) to new workbook, maintain column width
    By ovetcobo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2013, 03:47 PM
  5. [SOLVED] Need Filter+Export to PDF+Delete Filtered Items Macro
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-02-2012, 03:38 PM
  6. Export Filtered Result Values into new Sheet
    By pmpguy in forum Excel General
    Replies: 2
    Last Post: 07-02-2010, 10:38 AM
  7. Export (VBA) an Excel 2003 List (Filtered) to a txt/csv/xls
    By danielparra@yahoo.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2005, 07:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1