+ Reply to Thread
Results 1 to 3 of 3

Sorting data based upon "Rules" sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    09-16-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    17

    Question Sorting data based upon "Rules" sheet

    I am having trouble figuring out the best way of doing this. I would like to sort a group of data based upon the characteristics of each row. Here's the kicker, the inputs must be in a "Rules" worksheet, so that they can be viewed 'at a glance' and changed via hand. The Output spreadsheet should only output the list of names and their corresponding data that abides by all of the rules.

    I have gotten the first part done, which is getting the data stored into dictionaries, so that it can be recalled. Unfortunately, I don't know how to go about doing the next steps. I would be very appreciative of any help the VBA gods can give . I have attached a copy of the spreadsheet.

    Thanks,
    Mike
    Attached Files Attached Files

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Sorting data based upon "Rules" sheet

    I'd be tempted to change your ratio rule column to just a number rather than "Ratio 1"

    You could then replace all your code with the following:
    Public Sub sortIt()
    Dim rng As Range
    Dim arrFields As Variant
    Dim arrRules As Variant
    Dim x As Integer
    
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
    With Sheets("Rules")
        Set rng = .Range("A2").CurrentRegion.Offset(1, 2)
        arrRules = rng.Resize(rng.Rows.Count - 1, rng.Columns.Count - 2).Value
        arrFields = .Range("B2:B" & .Range("B2").End(xlDown).Row).Value
    End With
    
    
    With Sheet1.Range("B13:Q135")
        For x = 1 To UBound(arrRules)
            .AutoFilter Field:=arrFields(x, 1) + 1, Criteria1:=arrRules(x, 1) & arrRules(x, 2)
        Next x
        
        Sheet3.Cells.ClearContents
        Set rng = .SpecialCells(xlCellTypeVisible)
        If Not rng Is Nothing Then rng.Copy Sheet3.Range("A1")
        
    
    
    End With
    
        Sheet1.ShowAllData
        Sheet3.Cells.ClearFormats
    
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
    
    
    End Sub

  3. #3
    Registered User
    Join Date
    09-16-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Sorting data based upon "Rules" sheet

    Kyle, this looks like a promising start. I think I'll be able to work off of this. I'll keep you posted on how it goes. I appreciate the help from a fellow rugger (and/or fan)

    Mike

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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