formula dependant and independant value

sujittalukde

Well-known Member
Joined
Jun 2, 2007
Messages
520
Can a macro be provided to change the color of values in a cell of a sheet for the following:

1. The figures or values which are a result of formula in a sheet to color say red

2. the values which are consonant but used for formula in any sheet in a workbook to color say ble

3. The values which are neither a result of formula nor used for formula to stay black
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I assume that the purpose of this is to identify the 3 different types of cell as you have defined. In which case, you could always use Edit>GoTo>Special and then select either Precidents, Dependants, or Constants as desired.
 
Upvote 0
Code:
Sub test()
For Each Cell In Range("a1:G10")
    Cell.Font.ColorIndex = -4105
    x = ""
    On Error Resume Next
    x = Cell.Dependents.Address
    If x <> "" And Cell.HasFormula = False Then
        Cell.Font.ColorIndex = 5
    End If
    If Cell.HasFormula = True Then
        Cell.Font.ColorIndex = 3
    End If
Next Cell

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,495
Members
449,088
Latest member
Melvetica

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top