Dann halt so...
Show Plain Text
- Public Function WasDerBauerNichtFrisst(theValue As Range)
- Dim returnVal As String
- Dim theChar As Integer
- Dim replacement As String
- replacement = "_"
- returnVal = theValue.Text
- returnVal = Replace(returnVal, "Ä", "Ae")
- returnVal = Replace(returnVal, "Ö", "Oe")
- returnVal = Replace(returnVal, "Ü", "Ue")
- returnVal = Replace(returnVal, "ä", "ae")
- returnVal = Replace(returnVal, "ö", "oe")
- returnVal = Replace(returnVal, "ü", "ue")
- returnVal = Replace(returnVal, "ß", "ss")
- returnVal = Replace(returnVal, " ", "_")
- For i = 1 To Len(returnVal)
- theChar = AscW(Mid$(returnVal, i))
- ' A..Z a..z 0..9 &
- If (theChar >= 65 And theChar <= 90) Or _
- (theChar >= 97 And theChar <= 122) Or _
- (theChar >= 48 And theChar <= 57) Or _
- (theChar = 38) Then
- '' Frisst der Bauer
- Else
- '' Frisst er nicht
- returnVal = Left(returnVal, i - 1) & replacement & Mid(returnVal, i + 1)
- End If
- Next i
- WasDerBauerNichtFrisst = returnVal
- End Function
Die Funktion AscW liefert bei Excel für Mac nur eine Schätzung (heißt es) aber für's Nichtfressen wird es reichen. RegEx gibt es wohl auch nicht für VBA auf dem Mac. Ob der Zeichenbereich jetzt stimmt musst du mal prüfen.