jeudi 24 juin 2021

Trouble getting function to run once to alert across all worksheets

I am trying to run a Range code that If any value in a range is <1, it will alert the user. After trying multiple codes, this is the only one that doesn't run an error code. HOWEVER, it runs each page individually and is giving an incorrect answer. Please help!

Option Explicit
Sub Main()

Dim WS_Count As Integer
Dim i As Integer

WS_Count = ActiveWorkbook.Worksheets.Count
For i = 1 To 4

With WorksheetFunction
If .CountIf(Range("K3:K20"), "<1") > 0 Then
MsgBox "Rotations are needed"
Else
MsgBox "Rotations not needed"
End If
If .CountIf(Range("L3:L20"), "<1") > 0 Then
MsgBox "Functions are needed"
Else
MsgBox "Functions are NOT needed"
End If

End With
Next i


End Sub

Aucun commentaire:

Enregistrer un commentaire