Ich habe deine Anmerkung, dass du kein Basic sprichst, gesehen.
Aber wie wäre es mit einem fertigen Makro? ;-)
Das hat den Vorteil, dass die Formel =valid(...) nur eine Zelle
in deinem Spreadsheet belegt. Außerdem bekommt der Anwender
einen Hinweis darauf, wo in der Eingabe der erste Fehler ist.
~~Ab hier Basic-Code~~~~~~~~~
' Rolf Lochbühler, 2013-01-27
Option Explicit
Public Function valid( ByVal str As String ) As String
  Dim char As String
  Dim EXPECT_LEN As Integer
  Dim i As Integer
  Dim msg As String
  Dim STR_LEN As Integer
  EXPECT_LEN = Len( "XX-XXXXX-9999-X99-N999" )
  STR_LEN    = Len( str )
  If STR_LEN < EXPECT_LEN Then
    msg = "Eintrag " & CStr(EXPECT_LEN - STR_LEN) & " Zeichen zu
kurz."
  ElseIf STR_LEN > EXPECT_LEN Then
    msg = "Eintrag " & CStr(EXPECT_LEN - COUNT) & " Zeichen zu
lang."
  Else
    i   = 0
    msg = ""
    While msg = "" And i < STR_LEN
      i    = i + 1
      char = Mid(str,i,1)
      Select Case i
        Case 1, 2,   4, 5, 6, 7, 8,   15:
          If char < "A" Or char > "z" Then
            msg = "Erwarte Buchstabe statt " & char & " an Stelle
" & CStr(i) & "." End If
        Case 3,   9,   14,   18:
          If char <> "-" Then
            msg = "Erwarte Bindestrich statt " & char & " an
Stelle " & CStr(i) & "." End if
        Case 10, 11, 12, 13,   16, 17,   20, 21, 22:
          If char < "0" Or char > "9" Then
            msg = "Erwarte Ziffer statt " & char & " an Stelle "
& CStr(i) & "." End If
        Case 19:
          If char <> "N" Then
            msg = "Erwarte N statt " & char & " an Stelle 19."
          End if
      End Select
    Wend
  End If
  valid = "Ok"
  If msg <> "" Then
    valid = "Fehler: " & msg
  End If
End Function
~~Ende des Basic-Codes~~~~~~~~~
-rl
Am 2013-01-27 um 17:33 schrieb Stefan Weigel 
  Privacy Policy |
  
Impressum (Legal Info) |
  
Copyright information: Unless otherwise specified, all text and images
  on this website are licensed under the
  
Creative Commons Attribution-Share Alike 3.0 License.
  This does not include the source code of LibreOffice, which is
  licensed under the Mozilla Public License (
MPLv2).
  "LibreOffice" and "The Document Foundation" are
  registered trademarks of their corresponding registered owners or are
  in actual use as trademarks in one or more countries. Their respective
  logos and icons are also subject to international copyright laws. Use
  thereof is explained in our 
trademark policy.