Results 1 to 3 of 3
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Filtering an Excel file

    In the following Sub, an Excel sheet is filtered to the current value of the current report number, "RptNum". Does anyone know how to modify the filtering statement to filter column 1 to "RptNum" OR column 2 equal to the string "RU"?



    Code:
    Private Sub CreateMembersPDF(RptNum As String)
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '*  Create PDF file of filtered membership.  The worksheet is first filtered
    '*  to the current report number after creating the pdf file name.  Then,
    '*  the currently filtered sheet is exported to a pdf file.  Lastly, the
    '*  sheet filtering is turned off.
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    
    strPCMemFile = DLookup("PCFLoc", "tblPCF")
    strPCMemFile = strPCMemFile & Year(Date) & "-" & RptNum & "-Members.pdf"        ' Set Global variable for subsequent pdf appendage operation
    If Len(Dir(strPCMemFile)) > 0 Then _
        Kill (strPCMemFile)
    
    xlsApp.Worksheets("Membership").Activate
    xlsApp.Worksheets("Membership").AutoFilterMode = False
    xlsApp.Worksheets("Membership").[a1].AutoFilter 1, RptNum     <<<<<<<<<<<<<<<<<<<<<<<<<<
    
    xlsApp.ActiveSheet.PageSetup.PrintArea = "$A$1:$AA$60"
    xlsApp.ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=strPCMemFile, _
                                    Quality:=xlQualityStandard, IncludeDocProperties:=False, _
                                    IgnorePrintAreas:=False, OpenAfterPublish:=False
                                    
    xlsApp.Worksheets("Membership").AutoFilterMode = False
    
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Might want to post in an Excel forum. As far as can I tell from research, AutoFilter allows only one column. AdvancedFilter allows multiple columns but the filter criteria must be reference to cell range.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Ah! Just coming into the office to do just as you suggested. As you've already discovered, there is support for multiple columns but no clear way indicated as to how some logic can be applied. If someone in the Excel forum comes up with a usable suggestion I'll certainly post it here.
    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filtering single file usig dialog box
    By Ryobi in forum Access
    Replies: 7
    Last Post: 04-03-2018, 09:50 PM
  2. Replies: 34
    Last Post: 08-09-2017, 09:57 AM
  3. Replies: 5
    Last Post: 05-25-2016, 12:43 PM
  4. Replies: 2
    Last Post: 04-01-2016, 10:38 AM
  5. Import Excel file based on a date and time in file name
    By nhylan in forum Import/Export Data
    Replies: 4
    Last Post: 04-16-2013, 03:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums