Select constants

sujittalukde

Well-known Member
Joined
Jun 2, 2007
Messages
520
Can a macro be provided for selecting cells (including hidden) in the active sheet which are :

1. Totally consants ie not used in formula either in same sheet or other sheets

2. Constants ie figures used in formula in the same sheet and/or other sheets
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Thanks royuk,
I am very sorry I forget add one lines with my requirements

Totally consants ie not used in formula either in same sheet or other sheets (Font color Blue)

2. Constants ie figures used in formula in the same sheet and/or other sheets (Font color RED)
 
Upvote 0
Hi,

Define: IsConst

Refers to: =GET.CELL(48,INDIRECT("rc",FALSE))

Select the range and in Conditional formatting..

Condition 1

Formula Is: =AND(NOT(ISTEXT(A1)),LEN(A1)>0,IsConst=FALSE)

Color Blue

Condition 2

Formula Is: =AND(NOT(ISTEXT(A1)),LEN(A1)>0,IsConst)

Color Red

HTH
 
Upvote 0
Thanks Kris, but I was thinking for the same to merge with another macro and to make an addin Thats why I need a macro solution
 
Upvote 0
Thanks Kris, but I was thinking for the same to merge with another macro and to make an addin Thats why I need a macro solution

May be..

Code:
Sub test()
Dim RngC As Range, RngF As Range, Rng   As Range, r As Range
On Error Resume Next
Set RngC = Selection.SpecialCells(xlCellTypeConstants, 1)
Set RngF = Selection.SpecialCells(xlCellTypeFormulas, 1)
On Error GoTo 0

If Not RngC Is Nothing And Not RngF Is Nothing Then
    Set Rng = Union(RngC, RngF)
    ElseIf Not RngC Is Nothing And RngF Is Nothing Then
        Set Rng = RngC
    ElseIf RngC Is Nothing And Not RngF Is Nothing Then
        Set Rng = RngF
End If

For Each r In Rng
    If r.HasFormula Then
        r.Interior.ColorIndex = 3
    Else
        r.Interior.ColorIndex = 5
    End If
Next
End Sub
 
Upvote 0
Thnaks kris for the reply the code has one problem:

It is colouring Formula result as RED Whereas my need was that Those figures which are used for formula should be red. suppose 20 is a static value, but used for formula then color red. If not used for formula anywhere in the same WB say same sheet or other sheet, should be coloured RED.

It is colouring all constants as BLUE. suppose in the above eg., 20 is not used for any formula, then color it as BLUE else if used for formula color RED.

Thus, Formula results will be by default appear in red.
 
Upvote 0

Forum statistics

Threads
1,214,613
Messages
6,120,515
Members
448,968
Latest member
Ajax40

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