以下のようなIF条件があります。 ここでEntitySumは1です。条件が満足できるものではありませんが、Ifループに入ります。VBAコード条件が満たされない場合、Stlllがループに入る
Dim RowCount As Integer
Dim ColCount As Integer
Dim m, x As Integer
Dim EntitySum As Double
RowCount = Worksheets("Contribution").UsedRange.Rows.Count - 4
ColCount = Worksheets("Entities").UsedRange.Rows.Count - 4
m = 4
'outer loop for Rows
Do
EntitySum = 0
x = 6
m = m + 1
'inner loop for Columns
Do
x = x + 1
EntitySum = EntitySum + Worksheets("Contribution").Cells(m, x).Value
Loop Until x = ColCount + 6
If EntitySum <> 1 Then
MsgBox "The Entity Contribution at Row " & m & " is not 100%. Please Fix it to proceed further."
Exit Sub
End If
Loop Until m = RowCount + 4
それはVBAですべての問題ですか?
あなたの回答を感謝します。
おかげで、 リタ
「EntitySum」はどのように定義しましたか? –
これを 'String/Variant'と定義した場合、この' Val(Trim(EntitySum))<> 1 Then'を試してください。 –
はい私はEntitySumを定義しました。 Dim EntitySum Doubleとして – Rita