3
我有一個腳本,查看整個列,並尋找1 - 9之間的值,如果它遇到一個數字,它會拋出一個消息框,如果它不它目前拋出10個消息框,我知道這是因爲第二個框仍然在循環中。MsgBox出現多次...重新排列宏,所以它只顯示一次
我已經試過把它放在循環外,但沒有成功,任何指針會很棒,以獲得Else:MsgBox「所有位置正確輸入」來顯示一次!
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
完美...感謝這麼多,這是一個很好的清潔解決方案! – Methexis