Gruppe
UDF
Problem
Die Prüfziffer der in Spalte A eingetragenen Nummer soll geprüft werden. Prüfung als Formel und als VBA-Makro.
StandardModule: basMain
Function Module11(strNo As String) As Boolean
Dim iCounter As Integer
Dim iValue As Integer
iValue = CInt(Left(strNo, 1)) * 2
For iCounter = 2 To 7
iValue = iValue + CInt(Mid(strNo, _
iCounter, 1)) * (7 - iCounter + 2)
Next iCounter
iValue = 11 - (iValue Mod 11)
If iValue = 10 Or iValue = 11 Then iValue = 0
If iValue = CInt(Right(strNo, 1)) Then Module11 = True
End Function
Sub Eintragen()
Dim iRow As Integer
iRow = 2
Do Until IsEmpty(Cells(iRow, 1))
Cells(iRow, 3) = Module11(Cells(iRow, 1).Text)
If Cells(iRow, 3) = False Then
Cells(iRow, 1).Interior.ColorIndex = 3
Else
Cells(iRow, 1).Interior.ColorIndex = _
xlColorIndexNone
End If
iRow = iRow + 1
Loop
End Sub