Hello guys
I am developing a form in VBA that has "Text 1" and "Text 2" which are trying to subtract between them and show the result in Text3. I am currently using a macro below which is working.
My problem is that when I'm trying to create a validation, in which, for example, if the user types "Text 1" = 1000 and not "Text 2" = 2000, I would like the vba to display a message to the user such as "Text1" cannot be less than "Text2".and a reset Text1 and Text 2 and Text3.
Could you please help me?
I am developing a form in VBA that has "Text 1" and "Text 2" which are trying to subtract between them and show the result in Text3. I am currently using a macro below which is working.
My problem is that when I'm trying to create a validation, in which, for example, if the user types "Text 1" = 1000 and not "Text 2" = 2000, I would like the vba to display a message to the user such as "Text1" cannot be less than "Text2".and a reset Text1 and Text 2 and Text3.
Could you please help me?
VBA Code:
Sub SubtrairTXT()
'
On Error Resume Next
If Text1.Value <> "" And Text2.Value <> "" Then
If Text1.Value >= 0 And Text2.Value >= 0 Then
Text3.Value = Text1.Value - Text2.Value
Text3.Value = Format(Text3.Value, "$#,##0.00;-$#,##0.00")
Else
Cancel = True
End If
Else
Cancel = True
End If
End Sub