Conditional Format for Object
Thank you both...very much appreciated.
"JLatham" wrote:
The key to your code (which is definitely an option) for the shape is knowing
the name of the shape; Pivot Man, easy way to find that is to simply click on
the object and look at the Name Box. The Name Box is that area that normally
shows the cell address of the current cell: just above the '1' for row
numbers, and to the left of the "A" column designator.
"Socratis" wrote:
I concur with JLatham, but if you want to be able to format an object
conditionally, you might want to use the following macro.
Public Sub FormatCircle()
Dim cir As Shape
' Assuming your shape (Oval 5) is on worksheet (Sheet1).
Set cir = Worksheets("Sheet1").Shapes("Oval 5")
cir.Line.ForeColor.RGB = vbRed
Dim cell As Range
Set cell = Selection
Dim value As Long
value = cell.value
' use whatever range you like here
If value < 10 Then
cir.Line.ForeColor.RGB = vbRed
ElseIf value 20 Then
cir.Line.ForeColor.RGB = vbGreen
Else
cir.Line.ForeColor.RGB = vbYellow
End If
End Sub
similarly, you can use the following macro to format the desired range.
Public Sub FormatRangeConditionally()
Dim value As Long
value = Range("A1")
With Range("B2:B4")
If value < 10 Then
.Interior.Color = vbRed
ElseIf value 20 Then
.Interior.Color = vbGreen
Else
.Interior.Color = vbYellow
End If
End With
End Sub
Cheers,
socratis
"Pivot Man" wrote:
Looking to change the format of an object...change the color of a circle to
red if less than, yellow if between two values and green if greater than a
value. I can use condiitional formatting in a cell, just wondering if
A) you can apply condiitonal formatting to an object
or B) can you apply conditional formatting to cells outside of the result
cell. ie, depending on the results in cell A1, I want to change the color in
Cells B2 to B4.
Thanks
|