Conditional Formatting linked to String Length

WildWill

Board Regular
Joined
Sep 10, 2009
Messages
92
Hello

Please assist me with the following: I have a cell with a string of numbers that should always be 13 characters in length. I want to setup the cell using Conditional Formatting so that for any instance where the number of characters (always numbers), is either less than 13 or more than 13, that cell will be highlighted in red. How do I do this in Excel 2007?
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

G2K

Active Member
Joined
May 29, 2009
Messages
355
Try This :
Format - Cond. Formating - Formula is

Code:
=LEN($A$1)<> 13

Pattern - Choose Colour

* change cell value accordingly
 

WildWill

Board Regular
Joined
Sep 10, 2009
Messages
92
Try This :
Format - Cond. Formating - Formula is

Code:
=LEN($A$1)<> 13

Pattern - Choose Colour

* change cell value accordingly

One more feature that I need to add to the request: Can you change the solution so that it will only consider cells that are not empty? Right now, all my cells light up in red, event the empty ones. Thanks!
 

G2K

Active Member
Joined
May 29, 2009
Messages
355

ADVERTISEMENT

change the formula to -
Code:
=IF(OR(A1 ="",A1 =13),"",LEN(A1)<> 13)

* Change cell ref accordingly
 

G2K

Active Member
Joined
May 29, 2009
Messages
355
Sorry, previous formula is incorrect.

Please use below formula :
Code:
=IF(A1 ="","",LEN(A1)<> 13)
[/CODE]
 

dvahon

New Member
Joined
Nov 29, 2006
Messages
18

ADVERTISEMENT

I have a similar need. I need to know when the number of characters in a cell exceeds 30. I only need to know this for columns I-L. So I highlighted those columns... went to conditional formatting... in the formula portion put in =LEN($I:$L)>30 ... and in the formatting I chose to change the fill color to red.

Except it's not working... what am I doing wrong?
 

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
Usually you need to just enter the formula which applies to the top left cell in your range - that's I1 so formula should be just

=LEN(I1)>30

It adjusts automatically for the other cells in the range as long as you don't include $ signs
 

Watch MrExcel Video

Forum statistics

Threads
1,123,330
Messages
5,601,000
Members
414,419
Latest member
JRDunya

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
Top