snowbounduk
New Member
- Joined
- Apr 14, 2011
- Messages
- 21
Hello All,
I have the following code which I use to run through a number of sheets (SourceSheetNames), apply a filter, using criteria from MyCriteria and paste to worksheets, named as per the criteria.
I would like to do two things.
1. Change the field number for certain sheets
2. Add a second criteria to certain sheets.
Any help would be most appreciated!
I have the following code which I use to run through a number of sheets (SourceSheetNames), apply a filter, using criteria from MyCriteria and paste to worksheets, named as per the criteria.
I would like to do two things.
1. Change the field number for certain sheets
2. Add a second criteria to certain sheets.
Any help would be most appreciated!
Code:
Sub ACreateProjectReportsIncDps()
myCriteria = Sheets("Recd Plans").Range("C2:C159")
SourceSheetNames = Array("Slip No Issue", "Slip No Issue PP2", "Slip With Issue", "Slip To Left", "New MS", "Deleted", "Future Complete", "Past Incomplete", "No_Pres", "Estimated_Duration", "Overdue_Tasks")
For Each Crit In myCriteria
With Sheets(Crit)
Range(.Range("A1"), .Range("A1").End(xlDown)).EntireRow.Delete
.Range("A1").Value = "Project"
.Range("A2").Value = "Summary"
For Each SourceShtNme In SourceSheetNames
.Range("A1").End(xlDown).Offset(1).Value = SourceShtNme
Sheets(SourceShtNme).Range("B1").AutoFilter Field:=2, Criteria1:=Crit
Sheets(SourceShtNme).AutoFilter.Range.Copy .Range("A1").End(xlDown).Offset(1)
Sheets(SourceShtNme).Range("B1").AutoFilter Field:=2
Next SourceShtNme
End With
Next Crit
End Sub