PDA

View Full Version : Solved: custom format Required in a cell by code



محتاج2010
06-18-2011, 07:03 PM
How can i force the user to enter in cell (a1): then two characters and (-) and 3 zeros and one number? .As follows:
(FY-0008)

and wrong message.

shrivallabha
06-19-2011, 05:34 AM
1. Choose Data Validation
2. Select custom option
3. Paste following formula

=AND(LEFT(A1,3)="FY-",MID(A1,4,3)="000",ISNUMBER(ABS(RIGHT(A1,1))))
And you will be able to control it!!!

MickG
06-19-2011, 06:02 AM
Perhaps:-


If Not Left([a1], 6) Like "[A-Za-z][A-Za-z][\-][0][0][0]" Then
MsgBox "Please Enter first 6 characteres like Data ""Az-000"""
Else
MsgBox "Format OK"
End If

محتاج2010
06-19-2011, 08:51 AM
thank U verey much Shrivallabha Great idea of ​​your solution
..


MickG I am grateful to you