我有一个脚本可以查看整个列并查找 1 - 9 之间的值,如果遇到一个数字,它会抛出一个消息框,如果它当前没有抛出 10 个消息框,我知道这是因为第二个框仍然是 incide循环。
我曾尝试将其置于循环之外,但没有成功,任何指针都可以很好地让 Else: MsgBox "All locations correct entered" 显示一次!
Sub Scoring()
Dim FindString As String
Dim rng As Range
Dim startVal As Integer, endVal As Integer
startVal = 1
endVal = 9
For i = startVal To endVal
FindString = CStr(i)
With Sheets("Scoring").Range("S:S")
Set rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
MsgBox "There are one or more risks that do not contain the minimum information required for import, please ammend these and try again.", True
Exit For
Else: MsgBox "All locations correctly entered"
End If
End With
Next i
End Sub