PDA

View Full Version : Solved: Looking for values outside of a range



didig
05-11-2013, 10:05 AM
I'd like to write something to find values that are below 1 or above 5. and to highlight those cells in yellow.

I'd to select a range of cell, then start this code insert 1 as min.; 5 as max. And the code makes the cells with values <1 and values >5 yellow.

Can anyone help me pls. :help . Thanks :yes

Simon Lloyd
05-11-2013, 02:34 PM
Try this:Sub colour_it()
Dim ask1, ask2, Cel As Range
ask1 = Application.InputBox("Enter your start number", "Starting Value", , , , , , 1)
ask2 = Application.InputBox("Enter your End number", "Ending Value", , , , , , 1)
For Each Cel In Selection
If Cel.Value < ask1 Or Cel.Value > ask2 Then
Cel.Interior.ColorIndex = 6
End If
Next Cel
End Sub

didig
05-11-2013, 11:08 PM
Wow thanks a lot. I also like how u kept it simple.

my hat off to you (is this correct Eng.?)

^_^

sassora
05-12-2013, 12:11 AM
I would use conditional formatting here, unless it has to be in code.