• 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.

How to write intervals in VB

Gamnis

New Member
Hi All


I'm trying to write a VB code that vill help me marke all values between 7400 - 7500


I have tried something like this


------------------------------

Range("A4:A40").Select


Rng = Selection.Rows.Count

ActiveCell.Offset(0, 0).Select

Application.ScreenUpdating = False


For i = 1 To Rng

If ActiveCell.Value < 7400 Then

ActiveCell.Offset(1, 0).Select

Else

If ActiveCell.Value > 7500 Then

ActiveCell.Offset(1, 0).Select

Else

With Selection.Interior

.Pattern = xlSolid

.PatternColorIndex = xlAutomatic

.Color = 255

.TintAndShade = 0

.PatternTintAndShade = 0

End With

End If

End If

Next i

------------------------------


But it will not work.

If u can help me that would be great.


--

RG
 
Gamnis

Try this:

[pre]
Code:
Sub h()

For Each c In Range("A4:A40")
If c.Value > 7400 And c.Value < 7500 Then
With c.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next
End Sub
[/pre]
 
Back
Top