Results 1 to 1 of 1

Filter Problem On Multiple Columns

Threaded View

  1. #1
    Registered User
    Join Date
    10-08-2014
    Location
    Lake Havasu City, AZ
    MS-Off Ver
    Office 365
    Posts
    23

    Filter Problem On Multiple Columns

    Hello All,

    I have a sheet that I extract three unique criteria from my table. I then use this criteria to filter the main table by those three criteria. I am extracting unique values of a window construction list, totaling and pasting to a new sheet.

    I wrote a similar macro to filter a sheet by two unique criteria and it works great. The same macro on a different sheet will only work with one criteria. As soon as I add the second criteria I have no results in my table.

    The first two thirds of the macro work fine. I am intending to loop this macro as soon as I figure out the filter problem. My problem starts at the loop(I think).

    I have attached the file.

    Thanks for any input.

    John W


    This is my macro:
    Sub SortLWT()
    '
    ' SortLWT Macro
    '
    
     InputSheet = "Wood Parts"
     OutputSheet = "Job Sheet"
    '
    
    
    'Application.ScreenUpdating=False
        LastSortRow = Cells(Rows.Count, 3).End(xlUp).Row
      
    
    
        Cells.Select
        ActiveWorkbook.Worksheets(InputSheet).Sort.SortFields.Clear
        ActiveWorkbook.Worksheets(InputSheet).Sort.SortFields.Add Key:=Range("E:E"), _
            SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(InputSheet).Sort.SortFields.Add Key:=Range("D:D"), _
            SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets(InputSheet).Sort.SortFields.Add Key:=Range("C:C"), _
            SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets(InputSheet).Sort
            .SetRange Range("A1:J" & LastSortRow)
            .Header = xlGuess
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        
       Range("K1:S1").EntireColumn.Delete
        
        Dim IRange As Range
        Dim ORange As Range
        
        ' Find the size of today's dataset
        FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
        NextCol = Cells(1, Columns.Count).End(xlToLeft).Column + 2
        
        ' Set up output range. Copy heading from D1 there
        Range("C1").Copy Destination:=Cells(1, NextCol + 1)
        Range("D1").Copy Destination:=Cells(1, NextCol + 2)
        Range("E1").Copy Destination:=Cells(1, NextCol + 3)
        
        Set ORange = Cells(1, NextCol + 1).Resize(1, 3)
         
        
        ' Define the Input Range
        Set IRange = Range("A1").Resize(FinalRow, NextCol - 2)
        
        ' Do the Advanced Filter to get unique list of customers
        IRange.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ORange, Unique:=True
        
        'Filter the Range by Three uniques Columns M, N and O
        
        LastUniqueRow = Cells(Rows.Count, 13).End(xlUp).Row
        
        Range("A1:P" & FinalRow).Select
        Selection.NumberFormat = "0.0000"
        
          
        'For k = 2 To 3 'LastUniqueRow
        
                FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
                LengthValue = Cells(2, 13).Value
                WidthValue = Cells(2, 14).Value
                ThicknessValue = Cells(2, 15).Value
                
                Range("Q1").Value = LengthValue
                Range("R1").Value = WidthValue
                Range("S1").Value = ThicknessValue
                
                IRange.AutoFilter Field:=3, Criteria1:=LengthValue
                IRange.AutoFilter Field:=4, Criteria1:=WidthValue
                
                'IRange.AutoFilter Field:=5, Criteria1:=ThicknessValue
                
                'LastFilterRow = Cells(Rows.Count, 1).End(xlUp).Row
                'Range("B2:B" & FinalRow).Select
                'Range("B" & FinalRow + 1).Activate
                'ActiveCell.Value = LastFilterRow - 1
                'Range("C" & LastFilterRow).Resize(1, 3).Select
                'Selection.Copy
                'Range("C" & FinalRow + 1).Select
                'ActiveSheet.Paste
                'Application.CutCopyMode = False
                
                
            
                
            
           'Next k
        
        
        'Selection.AutoFilter
        
          
        
       
        
        Range("A1").Select
    
    '
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using filter to highlight/filter duplicates in multiple columns but within 1 day
    By DaveBre in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2014, 04:07 AM
  2. Macro to filter multiple columns of data to multiple work sheets
    By LISSANN in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2014, 07:24 PM
  3. Filter multiple columns based on multiple data validation fields
    By Jhunnieboy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-30-2014, 03:41 PM
  4. Filter Excel Data using vba multiple criteria multiple columns
    By pmyk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2013, 01:32 AM
  5. Replies: 2
    Last Post: 06-15-2012, 05:34 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