Trying2learnVBA
Board Regular
- Joined
- Aug 21, 2019
- Messages
- 67
- Office Version
- 365
- 2021
- Platform
- Windows
Hello,
I am trying to compare if two different cells have the same value as in positive or negative. This is the code I have, but it keeps returning my desired output when both cells have the same sign (either both positive or both negative)
Thank you for any pointers
I am trying to compare if two different cells have the same value as in positive or negative. This is the code I have, but it keeps returning my desired output when both cells have the same sign (either both positive or both negative)
VBA Code:
Sub Validations()
''''''''''''''''''''''''''''''''''''''''''''''
'Formulas to fill out counterparty validations'
''''''''''''''''''''''''''''''''''''''''''''''
Dim WS1 As Worksheet
Set WS1 = ThisWorkbook.Sheets("CounterParty MTM Validations")
With WS1
'BoA
.Range("B3").Value = .Range("A18")
.Range("B4").Value = .Range("F18")
.Range("B8").Value = .Range("A18")
.Range("B9").Value = .Range("D18")
If .Range("B10") >= 100000 Or .Range("B10") <= -100000 Then
.Range("A10").Value = "CALL"
Else
.Range("A10").Value = "NO CALL"
End If
'this is not working, it always returns "Changing position"
If .Range("A8") > 0 And .Range("A9") > 0 Then
.Range("A11").Value = "Changing Positions"
Else
.Range("A11").Value = ""
End If
'I would like the same cell "A11 to have the output "Changing position" if my conditions are met, but I am ok having the output in separate cells
If .Range("A8") < 0 And .Range("A9") < 0 Then
.Range("A12").Value = "Changing Positions"
Else
.Range("A12").Value = ""
End If
End With
End Sub
Thank you for any pointers