I
intrinsically.extragalactic
I have over a gig of spreadsheets that I need to digest immediately.
Step 1 is making it all easily visible.
What I want to do is write several Subs that can format cells dependent
up the cell value. Thanks to boards like this, I understand how to do
this.
What I am using now looks something like this:
----------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("AD353:AD802")) Is Nothing Then
Exit Sub
On Error GoTo CleanUp:
With Target
Select Case .Value
Case Is = 0: .Interior.ColorIndex = 2
.Font.ColorIndex = 2
Case 0.01 To 0.5: .Interior.ColorIndex = 6
Case 0.51 To 0.979: .Interior.ColorIndex = 4
Case 0.98 To 1.02: .Interior.ColorIndex = 41
Case Is > 1.02: .Interior.ColorIndex = 7
'etc.
End Select
End With
CleanUp:
Application.EnableEvents = True
End Sub
-----------------------------------------------------
This works well if all the cells have values.
***My problem is that I some of my columns that need to be formatted
(font and cell color) are defined as formula results [e.g. cell AD353
is "=IF(Q353=0,0,ROUND(R353/Q353,3))"]. I can't really get rid of these
formulas.
How do I make a macro that references a formula result? Is this
possible?
I've tried various foolishness such as using [Case
"=IF(Q353=0,0,ROUND(R353/Q353,3))" = 0: .Interior.ColorIndex = 2] and
that seemed to be an error.
Step 1 is making it all easily visible.
What I want to do is write several Subs that can format cells dependent
up the cell value. Thanks to boards like this, I understand how to do
this.
What I am using now looks something like this:
----------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("AD353:AD802")) Is Nothing Then
Exit Sub
On Error GoTo CleanUp:
With Target
Select Case .Value
Case Is = 0: .Interior.ColorIndex = 2
.Font.ColorIndex = 2
Case 0.01 To 0.5: .Interior.ColorIndex = 6
Case 0.51 To 0.979: .Interior.ColorIndex = 4
Case 0.98 To 1.02: .Interior.ColorIndex = 41
Case Is > 1.02: .Interior.ColorIndex = 7
'etc.
End Select
End With
CleanUp:
Application.EnableEvents = True
End Sub
-----------------------------------------------------
This works well if all the cells have values.
***My problem is that I some of my columns that need to be formatted
(font and cell color) are defined as formula results [e.g. cell AD353
is "=IF(Q353=0,0,ROUND(R353/Q353,3))"]. I can't really get rid of these
formulas.
How do I make a macro that references a formula result? Is this
possible?
I've tried various foolishness such as using [Case
"=IF(Q353=0,0,ROUND(R353/Q353,3))" = 0: .Interior.ColorIndex = 2] and
that seemed to be an error.