View Full Version : Solved: Cell formatting
blastpwr1970
04-15-2007, 07:50 AM
Hi,
 
Could somebody help me,
 
I need to change a cell base on the numbers entered.
 
A1
 
100
150
100
50
 
100
 
 
if any of the numbers in range A1:A10 changes higher that 150 then format H1 to a different color "red" and enter "out of range" in cell H1.
 
Thank you for all of your help in advance.
mdmackillop
04-15-2007, 08:02 AM
Hi Julio
Try this Worksheet sub.
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    Dim Rng As Range, Cel As Range
    If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
        With Range("H1")
            For Each Cel In Range("A1:A10")
                If Cel > 150 Then
                    .Interior.ColorIndex = 3
                    .Value = "out of range"
                    Exit Sub
                Else
                    .Interior.ColorIndex = xlNone
                    .Value = "OK"
                End If
            Next
        End With
    End If
End Sub
mdmackillop
04-15-2007, 08:07 AM
Hi Julio, 
I amended my code to avoid erroneous correction of the H1 cell when values changed.
blastpwr1970
04-15-2007, 08:13 AM
Hi,
 
I would like to to keep the formating, if any cell still out of range.
"H1" changes, if I update any of the values from "A1:A10" to anything else.
 
If is not too much to ask.
 
Thank you
mdmackillop
04-15-2007, 08:15 AM
My edited post should do this.  I just thought of that after posting.
blastpwr1970
04-15-2007, 08:20 AM
You are great it works' perfect.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.