Data Validation for a field formated as text that must show Numbers Only with a length of 4

USAMax

Well-known Member
Joined
May 31, 2006
Messages
843
Office Version
  1. 365
Platform
  1. Windows
I thought this would be easy but it is not working. In Data Validation I choose Allow Custom and this formula:

Code:
=AND(ISNUMBER(RC),IF(LEN(RC)>4,LEFT(RC,4),IF(LEN(RC) > 0, RIGHT("0000" & RC, 4),"")))

Everything I enter fails.

Examples of what I expect.

Out In
0004 4
0023 23
0548 548
4964 24964

Note: For alignment I put the output first.

THIS SHOULD WORK!
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I did discover one thing, as the cell if formatted as TEXT the ISNUMBER will fail so I had to change it to ISNUMBER(RC + 0) to get this portion of the formula to work.
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,292
Members
449,149
Latest member
mwdbActuary

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