Data Validation - No Spaces

DavidWe

New Member
Joined
May 15, 2006
Messages
24
I would like to not allow a user to enter spaces in a series of characters in a cell. I currently have the data validation set to text length = 7. There should be no spaces within those 7 characters. Is there a way to use the Data Validation function for this and still keep the text length limitation? I could probably write some code to have a message pop up but thought there might be another way. I don't want to just strip out the spaces or replace them with zeros because the sequence really needs to be seven characters and match another sequence of characters elsewhere. The user needs to be forced to enter seven characters without spaces. I will need to have this in 2003 and 2007. I think the solution will be the same for both versions.

Thanks for any help.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try using Data Validation with this custom formula (assuming data in A1)

=(LEN(A1)=7)*(LEN(SUBSTITUTE(A1," ",""))=7)
 
Upvote 0
Hi All, thought I'd re open this one rather than start a new thread, is there a way to modify the above to say characters can be either 3 or 4 long and no spaces.

So I would like users to be able to type "02A" "02AA" but NOT "02 A" which is why the no space is important.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,213,524
Messages
6,114,117
Members
448,549
Latest member
brianhfield

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