Can anyone help I am new to VBA? Below is a basic way to find rows that match 3 criteria, 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.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
How can I find or match to multiple criteria
<o></o>
How can I find or match to multiple criteria
Code:
[COLOR=blue][FONT=Verdana]Private Sub[/FONT][/COLOR][COLOR=black][FONT=Verdana] Average()
[/FONT][/COLOR][COLOR=darkgreen][FONT=Verdana]'
[/FONT][/COLOR][COLOR=black][FONT=Verdana] Application.ScreenUpdating = [/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana]
Call Openreport
Sheets("Data").Select
[/FONT][/COLOR][COLOR=darkgreen][FONT=Verdana] 'Needs to be variable range
[/FONT][/COLOR][COLOR=black][FONT=Verdana] Range("A8:P1413").Select
Range(Selection, Selection.End(xlDown)).Select
[/FONT][/COLOR][COLOR=darkgreen][FONT=Verdana]'Copy and paste main data for manipulation
[/FONT][/COLOR][COLOR=black][FONT=Verdana] Selection.copy
Sheets("AV").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana], Transpose:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana]
[/FONT][/COLOR][COLOR=darkgreen][FONT=Verdana] 'Sort columns by Catagory of Company then by Company Name and then by region scoring
[/FONT][/COLOR][COLOR=black][FONT=Verdana] Selection.Sort Key1:=Range("F2"), Order1:=xlAscending, _
Key2:=Range("E2"), Order2:=xlAscending, _
Key3:=Range("C2"), Order3:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana], _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana] Range(ActiveCell, ActiveCell.Offset(Range(0), 5)).Select
Selection.copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana], Transpose:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False
[/FONT][/COLOR][COLOR=darkgreen][FONT=Verdana] '
'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
[/FONT][/COLOR][COLOR=yellowgreen][FONT=Verdana] '
[/FONT][/COLOR][COLOR=black][FONT=Verdana]
[/FONT][/COLOR][COLOR=blue][FONT=Verdana]Do Until[/FONT][/COLOR][COLOR=black][FONT=Verdana] IsEmpty(ActiveCell)
[/FONT][/COLOR][COLOR=green][FONT=Verdana] 'Need find all maybe
'Needs to be veriable range
[/FONT][/COLOR][COLOR=red][FONT=Verdana] Range("A2:F?").Find(what:=Cells(F1, E1, C1), LookAt:=xlWhole, _
LookIn:=xlValues, _
[/FONT][/COLOR][COLOR=black][FONT=Verdana] searchorder:=xlByColumns).Activate
[/FONT][/COLOR][COLOR=darkgreen][FONT=Verdana]'If Match found Then
[/FONT][/COLOR][COLOR=black][FONT=Verdana] ActiveCell.EntireRow.Select
Selection.copy
Sheets("AVE").Select
[/FONT][/COLOR][COLOR=navy][FONT=Verdana]Do Until[/FONT][/COLOR][COLOR=black][FONT=Verdana] IsEmpty(ActiveCell)
Selection.Offset(1, 0).Select
[/FONT][/COLOR][COLOR=navy][FONT=Verdana]Loop[/FONT][/COLOR][COLOR=black][FONT=Verdana]
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana]
Sheets("AV").Select
ActiveCell.EntireRow.Delete
<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana] [/FONT][/COLOR][COLOR=darkgreen][FONT=Verdana]'Else[/FONT][/COLOR][COLOR=black][FONT=Verdana]
[/FONT][/COLOR][COLOR=blue][FONT=Verdana]If [/FONT][/COLOR][COLOR=black][FONT=Verdana]IsEmpty(ActiveCell) Then
[/FONT][/COLOR][COLOR=blue][FONT=Verdana]Call[/FONT][/COLOR][COLOR=black][FONT=Verdana] AV_Report
[/FONT][/COLOR][COLOR=blue][FONT=Verdana]Else[/FONT][/COLOR][COLOR=black][FONT=Verdana]
Sheets("AVE").Select
Range("A1").Select
ActiveCell.EntireRow.Select
Selection.copy
Sheets("AVER").Select
[/FONT][/COLOR][COLOR=navy][FONT=Verdana]Do Until[/FONT][/COLOR][COLOR=black][FONT=Verdana] IsEmpty(ActiveCell)
Selection.Offset(1, 0).Select
[/FONT][/COLOR][COLOR=blue][FONT=Verdana]Loop
[/FONT][/COLOR][COLOR=black][FONT=Verdana] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana], Transpose:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana]
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 _
:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False[/FONT][/COLOR][COLOR=black][FONT=Verdana], Transpose:=[/FONT][/COLOR][COLOR=blue][FONT=Verdana]False
[/FONT][/COLOR][COLOR=black][FONT=Verdana]
[/FONT][/COLOR][COLOR=navy][FONT=Verdana]End If
[/FONT][/COLOR][COLOR=black][FONT=Verdana] [/FONT][/COLOR][COLOR=darkgreen][FONT=Verdana]'End If[/FONT][/COLOR][COLOR=black][FONT=Verdana]
[/FONT][/COLOR][COLOR=navy][FONT=Verdana] Loop[/FONT][/COLOR][COLOR=black][FONT=Verdana]
[/FONT][/COLOR][COLOR=blue][FONT=Verdana]Call[/FONT][/COLOR][COLOR=black][FONT=Verdana] Closereport
Application.ScreenUpdating = [/FONT][/COLOR][COLOR=blue][FONT=Verdana]True[/FONT][/COLOR][COLOR=black][FONT=Verdana]
[/FONT][/COLOR][COLOR=blue][FONT=Verdana]End Sub[/FONT][/COLOR][COLOR=black][FONT=Verdana]<o:p></o:p>[/FONT][/COLOR]