Find a + sign in a cell, and format the cell?

andyreloaded

Board Regular
Joined
Aug 1, 2006
Messages
80
I have a spreadsheet that is mostly formulas. We may go in and append "+20" to one cell, and "-20" to another cell. Next month, when my formulas update, I don't want to forget that there is a manual adjustment nested in the cell after the formula.

Is there any way to make a conditional formula so that it will shade a cell if it contains a "+" sign or a "-" sign? Or if it contains a hard coded number?

This is a cell's contents that I would like to shade (because of the +20 on the end):

=ROUND(IFERROR(GETPIVOTDATA("Balance",iBSDATA!$A$3,"CoCd",G$1&"","FS Item",$A26),0),0)+20

Conditional formatting always gives me a headache, so any help would be greatly appreciated!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Just to clarify, what if the formula is
=A1+B1
Do you want that cell formatted too? I know it's a simplified example, but you get the idea...is it a plus sign *anywhere* in the formula, or just at the end. And if just at the end, what constitutes "end"...after the final closing parentheses, or not nested anywhere...the possibilities determine the CF logic.
 
Upvote 0
Just to clarify, what if the formula is
=A1+B1
Do you want that cell formatted too? I know it's a simplified example, but you get the idea...is it a plus sign *anywhere* in the formula, or just at the end. And if just at the end, what constitutes "end"...after the final closing parentheses, or not nested anywhere...the possibilities determine the CF logic.

In the spreadsheet, I was going to convert formulas like that to =Z1, and put A1+B1 in Z1, so that there would be no + or - signs in any of the summations or pivot table formulas. So any "+" or "-" at all would be shaded.

My initial thought was to use find(), but that didn't work, I guess because + is in the formula, and find is only looking at the formulas displayed results.
 
Upvote 0
Based on your description of the issue, here is how you can do this.

First, copy and paste the following UDF into a standard VBA module:

Code:
Function IsFormula(rng As Range) As Boolean
IsFormula = rng.HasFormula
If IsFormula = True Then
Dim strFormula$
strFormula = rng.Formula
If InStr(strFormula, "+") > 0 Then
IsFormula = True
Else
IsFormula = False
End If
End If
End Function

Next, select the range of cells that contain the formulas you want to evaluate. For example, let's say the range of cells is from K7:M35. Select that range, and when you do, the first cell you selected (K7 in this case in most instances) will be the active cell in that range. With that range selected, and cell K7 the active cell, bring up the conditional formatting dialog box. The formula rule for this would be
=IsFormula(K7)
Then select your fill color, click OK, and the cells with formulas that have a "+" operator in them will be conditionally formatted.

I just tested this and know it works, so if you get stuck, post back.
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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