ChesterKaup
New Member
- Joined
- Aug 19, 2010
- Messages
- 36
I have a worksheet array and would like to reference the same ranges on each worksheet to do some various thinks on each worksheet as I loop through them. My code fails on the range statement and I am unsure what to do. The .columns statement works fine. Below is the code. Thanks for any help.
For I = 0 To UBound(WorkSheetNames)
With Worksheets(WorkSheetNames(I))
.Columns("G:G").ColumnWidth = 10
.Range("N9:AM9").Select
.Selection.AutoFill Destination:=Range("N9:AM800"), Type:=xlFillDefault
.Range("N2").Select
.Range("N2").Formula = "=AVERAGEIFS(AF9:AF480,AF9:AF480,"">0"",A9:A480, ""<"" &N2)"
.Range("N3").Select
.Range("N3").Formula = "=AVERAGEIFS(AF9:AF480,AF9:AF480,"">0"",A9:A480, "">"" &N2)"
End With
Next I
For I = 0 To UBound(WorkSheetNames)
With Worksheets(WorkSheetNames(I))
.Columns("G:G").ColumnWidth = 10
.Range("N9:AM9").Select
.Selection.AutoFill Destination:=Range("N9:AM800"), Type:=xlFillDefault
.Range("N2").Select
.Range("N2").Formula = "=AVERAGEIFS(AF9:AF480,AF9:AF480,"">0"",A9:A480, ""<"" &N2)"
.Range("N3").Select
.Range("N3").Formula = "=AVERAGEIFS(AF9:AF480,AF9:AF480,"">0"",A9:A480, "">"" &N2)"
End With
Next I