Results 1 to 7 of 7

Advanced Filter

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Advanced Filter

    I am trying to get an advanced filter to work on a table. Its a simple filter on the sheet that the data is in called Datasheet in the field there are clas numbers from 1 to 9 sometimes less but no more than 9.

    My Goal is to create a seperate table for each class on sheet 3. The table will contain an id field, name field and 5 fields calculated from data on "Datasheet" . I recorded a macro to filter data but it fails at "Field=3" in my code. "Field 3 = column C".

    If you can help with any part of the filter that would be awesome.
    Sub Filternums()
    '
    ' Filternums Macro
    '
    
    '
        Dim NumRge As String
        Dim ClassCount As Integer
        ARange = Worksheets("sheet3").Range("C:C") to LastRow
        BRange = Worksheets("sheet3").Range("D:D") to LastRow
    '   NewTable = Worksheets("sheet3").LastRow + 1 Row
        x = 1 <= 9
        NumRge = .ListObjects("Table2").Range.AutoFilter Field:=3, Criteria1:=x Operator:=xlAnd) ' copied from recorded macro but error at Field
        .Action:=xlFilterCopy
        With Sheets("Datasheet")
         
    '    Find the last row and return count of rows minus header
         ClassCount = Cells(Rows.Count, "C").End(xlUp).Row - 1 ' Count number of rows from Lastrow and minus 1 for header
    '    Copy list of ids and names from from column M and N to Sheet 3
    '    On next loop copy to sheet three leaving a row after last table
    '    Some Calculation for condition 1 - paste to sheet3 from C
    '    Some Calculation for condition 2 - paste to sheet3 From D
    '    Fromat sheet 3 as table 1 on next loop table 2 etc
    '    Ensure number format and data bars
    '    With
            .NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
            .FormatConditions.AddDatabar ' Add Conditional Data bars
            .FormatConditions(Selection.FormatConditions.Count).ShowValue = True
            .FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
            With .FormatConditions(1)
                .MinPoint.Modify newtype:=xlConditionValueLowestValue
                .MaxPoint.Modify newtype:=xlConditionValueHighestValue
                With .BarColor
                    .Color = 13012579
                    .TintAndShade = 0
                End With
            End With
        End With
        Next x
    End Sub
    Last edited by flebber; 08-20-2010 at 07:19 AM. Reason: Update to code

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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