• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Code for Less than and greater than

Hi Team,


I need help to get VBA code to Check if the Value in Cell A5 is not less than -10 and Greater than 10 then the Value in A5 should be copied and pasted in column E.


if A5 Value is -6 it should not paste any value in column E


if A5 Value is 16 it should paste the value in column E


thank you

Raghava Sharma
 
I think this is what you asked for.

[pre]
Code:
Sub CheckValues()
Dim MyValue As Double
MyValue = Range("A5").Value
If MyValue >= -10 And MyValue <= 10 And MyValue <> -6 Or MyValue = 16 Then
Range("E5") = MyValue
End If
End Sub
[/pre]
 
Good day

Could you not do this with formula..IF(A1>=10,A1,0)if your data was in A1 and this formula was in B1, B1 would take any value equal or greater than 10. I do nor use VBA at the moment (still learning excel)so formulas are my way
 
Good point bobhc. I think formula in E5 would be:

=IF(OR(A5=16,AND(A5>=-10,A5<=10,A5<>-6)),A5,"")
 
Back
Top