View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Data validation/Formatting input

XL's parser runs before both Validation and any event macros, so one
can't force an entry in any particular format.

If you use a userform, you can check each keystroke as it's entered into
a textbox, for example.

OTOH, why do you care what format the date is entered as, as long as
it's a date (which you can test, either by formula or event macro)? Just
format the cell the way you want to display it.

As for the 0000\.0000\.00 format, AFAIK, there's no way to fill from the
left without using an event macro to manipulate the entry. Perhaps
something like:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target(1)
If Not Intersect(.Cells, Range("A1")) Is Nothing Then
Application.EnableEvents = False
If IsNumeric(.Value) Then
.ClearFormats
.Value = Left(Replace(.Text, ".", "") & _
String(10, "0"), 10)
.NumberFormat = "0000\.0000\.00"
Else
.Clear
End If
Application.EnableEvents = True
End If
End With
End Sub








In article .com,
"Wescotte" wrote:

Is it possible to force the user to enter text in a very specific
format like for entering dates or similar syntax specific input?

Also, I setup a custom format of 0000"."0000"."00

When the user enters 123 it it switched to
0000.0001.23

Is it possible to reverse it so it would become 1230.0000.00 instead?