Be sure comma is there and in the right place

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
Ok in City state and Zip

I must have the comma next to the city.
We should alway be typing 2 letters for the state and numbers after the state.

So can I somehow find the numbers on the right to the left of them will be my 2 letter state than any text before that must have the comma following the last word of the first part of text. And maybe do Data Validation???
We might have:
(the underscore represents an unwanted space)
Conway, TN 12345
Conway_, TN 12345 ' Needs to be validated because of the space
Conway, TN 12345-1234
San Jose, GA 12354
San Jose_, GA 12354 ' Needs to be validated because of the space
Research Triangle Park, NC 12365
Or maybe an omitted comma?
San Jose GA 12354 'Validate because of no comma

Thank You in advance,
Michael
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
This is maybe one solution?
Excel Workbook
AB
1Conway, TN 12345No problems
2Conway , TN 12345Needs to be validated because of the space
3Conway, TN 12345-1234No problems
4San Jose, GA 12354No problems
5San Jose , GA 12354Needs to be validated because of the space
6Research Triangle Park, NC 12365No problems
7San Jose GA 12354Validate because of no comma
Sheet3
Cell Formulas
RangeFormula
B1=IF(ISERROR(SEARCH(",",A1)),"Validate because of no comma",IF(MID(A1,SEARCH(",",A1)-1,1)=" ","Needs to be validated because of the space","No problems"))

Not sure it will catch all of your problems though? I guess you could check if the value before the comma was a letter if you really wanted to?
 
Upvote 0
Can I do this in Data Validation?
Or should I use VBA On_Worksheet_Change
All my cells next to this are being used.

Michael
 
Upvote 0
You should be able to use this for data validation maybe?

=and(isnumber(SEARCH(",",A1)),MID(A1,SEARCH(",",A1)-1,1)<>" ")
 
Upvote 0
It says the value equates to an error do you want to continue.
This is a file that has to be for excel 2000, 2003 and 2007 would that be why maybe it is not working?

Michael
 
Upvote 0
I tried this:
=IF(ISERROR(AND(ISNUMBER(SEARCH(",",B4)),MID(B4,SEARCH(",",B4)-1,1)<>" ")),FALSE,AND(ISNUMBER(SEARCH(",",B4)),MID(B4,SEARCH(",",B4)-1,1)<>" "))

But now, I tried to enter wrong ones and right ones and it does not validate at all??

Any ideas?
Michael
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,248
Members
452,900
Latest member
LisaGo

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