Closed Thread
Results 1 to 3 of 3

Thread: Mr Excel could not solve this

  1. #1
    Registered User
    Join Date
    04-02-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Mr Excel could not solve this

    Can anyone help I am new to VBA or I copy and paste then test? Below should be a basic way to find rows that match 3 criteria from row 1, work out the average to each column G to M of all the rows that match the criteria and copy and past to a repot sheet.

    How can I find or match to multiple criteria



    Private Sub Average()
    '
        Application.ScreenUpdating = False
        Call Openreport
        Sheets("Data").Select
        
        'Needs to be variable range
        Range("A8:P1413").Select
        Range(Selection, Selection.End(xlDown)).Select
        
        'Copy and paste main data for manipulation
        Selection.copy
        Sheets("AV").Select
        Range("A2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        
        'Sort columns by Catagory of Company then by Company Name and then by region scoring
        Selection.Sort Key1:=Range("F2"), Order1:=xlAscending, _
                        Key2:=Range("E2"), Order2:=xlAscending, _
                        Key3:=Range("C2"), Order3:=xlAscending, _
                        Header:=xlNo, _
                        OrderCustom:=1, _
                        MatchCase:=False, _
                        Orientation:=xlTopToBottom, _
                        DataOption1:=xlSortNormal, _
                        DataOption2:=xlSortNormal, _
                        DataOption3:=xlSortNormal
                        
        Range(ActiveCell, ActiveCell.Offset(Range(0), 5)).Select
                Selection.copy
                Range("A1").Select
                Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                    :=False, Transpose:=False
        '
        '1 copy paste row 2 to row 1 in sheet "AV"
        '2 Find first row that matches F1,E1,C1 after row 1
        '3 If match found, copy row 2 to sheet "AVE" to the first empty row
        '4 delete row 2 in sheet "AV"
        '5 loop stage 1
        '6 If no match found
        '7 copy  row 1 in sheet "AVE" (range G1:M1 sum average down on   sheet to give total average score)
        'to first empty row in sheet "AVER"
        '8 delete rows not empty after row 3 in sheet "AVE"
        '9 Loop stage 1 until row 2 empty
        '
        
        Do Until IsEmpty(ActiveCell)
             
                
                    
                'Need find all maybe
                'Needs to be veriable range
                Range("A2:F?").Find(what:=Cells(F1, E1, C1), LookAt:=xlWhole, _
                                                        LookIn:=xlValues, _
                                                        searchorder:=xlByColumns).Activate
            'If Match found Then
                ActiveCell.EntireRow.Select
                Selection.copy
                Sheets("AVE").Select
                Do Until IsEmpty(ActiveCell)
                    Selection.Offset(1, 0).Select
                Loop
                Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                    :=False, Transpose:=False
                Sheets("AV").Select
                ActiveCell.EntireRow.Delete
                
    'Else
                    If IsEmpty(ActiveCell) Then
                        Call AV_Report
                
                    Else
                    Sheets("AVE").Select
                    Range("A1").Select
                    ActiveCell.EntireRow.Select
                    Selection.copy
                    Sheets("AVER").Select
                        Do Until IsEmpty(ActiveCell)
                            Selection.Offset(1, 0).Select
                        Loop
                        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                            :=False, Transpose:=False
                            
                    Sheets("AV").Select
                    Range("A2").Select
                    Range(ActiveCell, ActiveCell.Offset(Range(0), 5)).Select
                    Selection.copy
                    Range("A1").Select
                    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                    :=False, Transpose:=False
                    
                    End If
    'End If
          Loop
        
        
       
        Call Closereport
        Application.ScreenUpdating = True
    End Sub
    Last edited by OpusOpus; 04-02-2010 at 04:01 PM. Reason: Desperation, Got it?

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Mr Excel could not solve this

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then amend your thread title accordingly.

    Thanks.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003 & 2007
    Posts
    3,714

    Smile Re: Mr Excel could not solve this

    When you read the rules also make sure you pay attention to the one about cross posting.
    Next time make sure you post a link.
    http://www.mrexcel.com/forum/showthread.php?t=459288

    Also, five hours without a response doesn't mean all hope is lost on this, or any other forum.

    DominicB

Closed Thread

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.2.0