Data Validation in IF statement

CHSLax60

New Member
Joined
Jun 6, 2011
Messages
15
If I have a field for SSNs, can I confirm that it contains exactly 9 characters? I can't use data validation becase the data could be pasted in. Can I count the number of characters in a cell? The goal is to tell the user that he/she input invalid data. Likewise, if they attempt to paste an "undesirable" character (ie., #, &, $, etc.) into a cell. Can I evaluate that as well?

Excel really needs to have a way to force validation on pasted data.:oops:
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
An easy solution would be in the cell next where you want paste the data

=IF(LEN(B3)=9,"","Invalid data")
 
Upvote 0
Thanks, it's always the simplest things that you overlook. Now does anyone have something simple on identifing invalid characters so I can really feel like the weekend can't get here soon enough.
 
Upvote 0
Try (two methods):
Excel 2010
ABCDE
1, dfadsfad#, &, $,TRUETRUE
2fdadf&TRUETRUE&
3$faefa &TRUETRUE#
4fasdfadsfFALSEFALSE$

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B1=SUMPRODUCT(--(COUNTIF(A1,{"*#*","*&*","*$*"})))>0
C1=SUMPRODUCT(--(ISNUMBER(SEARCH($E$2:$E$4,A1))))>0

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,219,162
Messages
6,146,659
Members
450,706
Latest member
LGVBPP

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