andrevni22
New Member
- Joined
- Dec 21, 2022
- Messages
- 9
- Office Version
- 2021
- Platform
- Windows
I am working with arrays now and the IF statement is judging wrong. I resumed my code:
Sub Reset()
Nr=6
Dim X, Y, MinX, AM, NX, W As Double
Y=200,00
AM=5,00
ReDim X(Nr)
ReDim Z(Nr)
For i = 1 To NrParcelas
X(i - 1) = Y - WorksheetFunction.Sum(.Range(.Cells(2, LTi.Column + i - 1), .Cells(10, 2 + i - 1)))
Z(i - 1) = X(i - 1)
W(i - 1) = 0
NX(i - 1) = X(i - 1)
Next i
MinX = Format(Application.Min(X), "0.00")
' MinX =10 in my case
If MinX >= AM Then
'code 1
End If
If MinX < AM Then
'code 2
end if
end sub
The Problem is that MinX is > than AM and it is not going into the first IF statement (code 1), but in the second. I do not know if I decalred the variables correctly, or something else. If MinX is < AM, it ins going into the second statement as well (code 2).
Could please someone help me? I am more than weeks in this issue... Many Thanks in Advance.
Sub Reset()
Nr=6
Dim X, Y, MinX, AM, NX, W As Double
Y=200,00
AM=5,00
ReDim X(Nr)
ReDim Z(Nr)
For i = 1 To NrParcelas
X(i - 1) = Y - WorksheetFunction.Sum(.Range(.Cells(2, LTi.Column + i - 1), .Cells(10, 2 + i - 1)))
Z(i - 1) = X(i - 1)
W(i - 1) = 0
NX(i - 1) = X(i - 1)
Next i
MinX = Format(Application.Min(X), "0.00")
' MinX =10 in my case
If MinX >= AM Then
'code 1
End If
If MinX < AM Then
'code 2
end if
end sub
The Problem is that MinX is > than AM and it is not going into the first IF statement (code 1), but in the second. I do not know if I decalred the variables correctly, or something else. If MinX is < AM, it ins going into the second statement as well (code 2).
Could please someone help me? I am more than weeks in this issue... Many Thanks in Advance.