M
Martin Wheeler
XL2000
The code below only works on the active sheet. My app runs through 10
sheets of a workbook so I need this to work on each sheet, if applicable.
Any help would be greatly appreciated.
Ta,
Martin
Public Sub BotW(wks As Worksheet)
Application.ScreenUpdating = False
On Error Resume Next
With wks
A = Application.WorksheetFunction.Min(.Range("Q13:Q18"))
B = Application.WorksheetFunction.Small(.Range("Q13:Q18"), "2")
C = Application.WorksheetFunction.CountIf(.Range("L13:L20"),
"<-.05")
D = Application.WorksheetFunction.CountIf(.Range("Q13:Q18"),
"<-.495")
E = Application.WorksheetFunction.CountIf(.Range("Q13:Q18"),
"<-.495")
F = Application.WorksheetFunction.Small(.Range("Q13:Q18"), "3")
G = Application.WorksheetFunction.CountIf(.Range("P7
10"),
"<-.245")
H = Application.WorksheetFunction.CountIf(.Range("P11
22"),
"<-.295")
I = Application.WorksheetFunction.CountIf(.Range("P7
22"),
"<-.195")
G = G + H
I = I + H
If .Range("E2").Value < 9 Or .Range("G1").Value < 10000 Or
..Range("K7").Value < 1.7 Then
Exit Sub
Else
If .Range("G1").Value < 50000 And G > 6 Or I > 5 And
..Range("G1").Value >= 50000 Then
Exit Sub
Else
If A = 1 And B = 2 And F = 3 Then
Exit Sub
Else
Set Start = Cells.Find(what:=A, _
After:=.Range("Q12"), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=True)
Set CellK = Start.Offset(0, -6)
Set CellP = Start.Offset(0, -1)
If A <= 4 And C <= 2 And CellK < 40 And CellP < -0.175
Then
.Range("P6").Value = "DoNow"
End If
End If
End If
End If
Application.ScreenUpdating = True
End With
End Sub
The code below only works on the active sheet. My app runs through 10
sheets of a workbook so I need this to work on each sheet, if applicable.
Any help would be greatly appreciated.
Ta,
Martin
Public Sub BotW(wks As Worksheet)
Application.ScreenUpdating = False
On Error Resume Next
With wks
A = Application.WorksheetFunction.Min(.Range("Q13:Q18"))
B = Application.WorksheetFunction.Small(.Range("Q13:Q18"), "2")
C = Application.WorksheetFunction.CountIf(.Range("L13:L20"),
"<-.05")
D = Application.WorksheetFunction.CountIf(.Range("Q13:Q18"),
"<-.495")
E = Application.WorksheetFunction.CountIf(.Range("Q13:Q18"),
"<-.495")
F = Application.WorksheetFunction.Small(.Range("Q13:Q18"), "3")
G = Application.WorksheetFunction.CountIf(.Range("P7

"<-.245")
H = Application.WorksheetFunction.CountIf(.Range("P11

"<-.295")
I = Application.WorksheetFunction.CountIf(.Range("P7

"<-.195")
G = G + H
I = I + H
If .Range("E2").Value < 9 Or .Range("G1").Value < 10000 Or
..Range("K7").Value < 1.7 Then
Exit Sub
Else
If .Range("G1").Value < 50000 And G > 6 Or I > 5 And
..Range("G1").Value >= 50000 Then
Exit Sub
Else
If A = 1 And B = 2 And F = 3 Then
Exit Sub
Else
Set Start = Cells.Find(what:=A, _
After:=.Range("Q12"), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=True)
Set CellK = Start.Offset(0, -6)
Set CellP = Start.Offset(0, -1)
If A <= 4 And C <= 2 And CellK < 40 And CellP < -0.175
Then
.Range("P6").Value = "DoNow"
End If
End If
End If
End If
Application.ScreenUpdating = True
End With
End Sub