Specific Validation (RegEx?) without VBA?

MartinS

Active Member
Joined
Jun 17, 2003
Messages
489
Office Version
  1. 365
Platform
  1. Windows
I am trying to find out if I can achieve something in Excel to apply some validation, but without using VBA if possible?
I have a requirement to validate a column to allow either NNNNNNN.NN or NNNNNNN.NN.NN (N always being numeric). The data will then be imported into SQL by another process, but the requirement is for the user to not enter 'rubbish' before the import process starts, but they also want the worksheet that contains the data to be copied/pasted to other workbooks, so having VBA behind it would not work for sheet once it was in another workbook. If VBA is the only option then we will consider an add-in but before we go down that road, I wanted to check to see if there was something I'm missing with data validation?
Thanks in advance
Martin
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I haven't tested extensively, but a custom validation formula something like this should work:

=AND(OR(LEN(A1)=10,LEN(A1)=13),ISNUMBER(--LEFT(A1,7)),ISNUMBER(--RIGHT(A1,2)),MID(A1,8,1)=".",IF(LEN(A1)=13,ISNUMBER(--MID(A1,9,2)),TRUE))

where A1 is the cell you are validating.
 
Upvote 0
Slightly different:

=AND(ISNUMBER(--SUBSTITUTE(A1,".","")),OR(LEFT(RIGHT(A1,3))=".",AND(LEFT(RIGHT(A1,6))=".",LEFT(RIGHT(A1,3))=".")),OR(LEN(A1)=10,LEN(A1)=13))
 
Last edited:
Upvote 0
Thanks guys, really helpful. I shall give these a try but they both look to be doing exactly what I'm looking for.
Thanks again
Martin
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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