Dann halt so...

Show Plain Text
  1. Public Function WasDerBauerNichtFrisst(theValue As Range)
  2.     Dim returnVal As String
  3.     Dim theChar As Integer
  4.     Dim replacement As String
  5.     replacement = "_"
  6.  
  7.     returnVal = theValue.Text
  8.    
  9.     returnVal = Replace(returnVal, "Ä", "Ae")
  10.     returnVal = Replace(returnVal, "Ö", "Oe")
  11.     returnVal = Replace(returnVal, "Ü", "Ue")
  12.     returnVal = Replace(returnVal, "ä", "ae")
  13.     returnVal = Replace(returnVal, "ö", "oe")
  14.     returnVal = Replace(returnVal, "ü", "ue")
  15.     returnVal = Replace(returnVal, "ß", "ss")
  16.     returnVal = Replace(returnVal, " ", "_")
  17.    
  18.     For i = 1 To Len(returnVal)
  19.         theChar = AscW(Mid$(returnVal, i))
  20.                
  21.         ' A..Z a..z 0..9 &
  22.         If (theChar >= 65 And theChar <= 90) Or _
  23.                 (theChar >= 97 And theChar <= 122) Or _
  24.                 (theChar >= 48 And theChar <= 57) Or _
  25.                 (theChar = 38) Then
  26.             '' Frisst der Bauer
  27.         Else
  28.             '' Frisst er nicht
  29.             returnVal = Left(returnVal, i - 1) & replacement & Mid(returnVal, i + 1)
  30.         End If
  31.     Next i
  32.  
  33.     WasDerBauerNichtFrisst = returnVal
  34. 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.