E
everythingautomotive
is it possible to change the color of all cells that contain a formula
or are part of a formula???
if so, how would i do that?
or are part of a formula???
if so, how would i do that?
is it possible to change the color of all cells that contain a formula
or are part of a formula???
if so, how would i do that?
Yes, use that formula in conditional formatting. Seehttp://www.contextures..com/xlCondFormat01.html
--
---
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
- Show quoted text -
You could get all the cells at once, too:
is it possible to change the color of all cells that contain a formula
or are part of a formula???
if so, how would i do that?
Neat. I didn't realize that.
You could make the routine even shorter:
=========================
Sub ColorFormulas()
On Error Resume Next
Cells.SpecialCells(xlCellTypeFormulas).Interior.Color = vbYellow
End Sub
==========================
--ron
As I read this, what do you mean by cells that "are part of a formula"?
If you mean what I think, then perhaps:
=========================
Sub ColorFormulas()
On Error Resume Next
With Cells.SpecialCells(xlCellTypeFormulas)
.Interior.Color = vbYellow
.Precedents.Interior.Color = vbRed
End With
End Sub
============================
Of course, as written, if you make changes, the already colored cells may not
change.
It would be simplest to first set the format to "none" for the worksheet, and
then just color the formulas and precedents. But this may not be appropriate.
==============================
Sub ColorFormulas()
On Error Resume Next
Cells.Interior.ColorIndex = xlNone
With Cells.SpecialCells(xlCellTypeFormulas)
.Interior.Color = vbYellow
.Precedents.Interior.Color = vbRed
End With
End Sub
===============================
--ron
As I read this, what do you mean by cells that "are part of a formula"?
If you mean what I think, then perhaps:
=========================
Sub ColorFormulas()
On Error Resume Next
With Cells.SpecialCells(xlCellTypeFormulas)
.Interior.Color = vbYellow
.Precedents.Interior.Color = vbRed
End With
End Sub
============================
Of course, as written, if you make changes, the already colored cells may not
change.
It would be simplest to first set the format to "none" for the worksheet, and
then just color the formulas and precedents. But this may not be appropriate.
==============================
Sub ColorFormulas()
On Error Resume Next
Cells.Interior.ColorIndex = xlNone
With Cells.SpecialCells(xlCellTypeFormulas)
.Interior.Color = vbYellow
.Precedents.Interior.Color = vbRed
End With
End Sub
===============================
--ron
If D11 has formula that says "=A1+A3+B4", I want cells D11, A1, A3 &
B4 all to be shaded. maybe I am doing something wrong but all of
this
stuff when I run the macros only shades D11 (the one with the actual
formula).
You probably were running my first recommendation, and not the most recentone:
Sub ColorFormulas()
On Error Resume Next
Cells.Interior.ColorIndex = xlNone
With Cells.SpecialCells(xlCellTypeFormulas)
.Interior.Color = vbYellow
.Precedents.Interior.Color = vbRed
End With
End Sub
--ron
that definately works. if i wanted the sheet to change the cell
colors as i am entering data is there a way to do that? or do i have
to keep running the macro over every so often?
You could try using a worksheet selection_change event. But, depending on the
size of your worksheet, it might slow things down.
For example, right click on the sheet tab and select View Code. Then paste
this into the window that opens:
-----------------------
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error Resume Next
Cells.Interior.ColorIndex = xlNone
With Cells.SpecialCells(xlCellTypeFormulas)
.Interior.Color = vbYellow
.Precedents.Interior.Color = vbRed
End With
Application.EnableEvents = True
End Sub
Absolute Genious!!!
That works FANTASTIC. Thank you so much.
I am slowly learning<g>