title: basic syntax error in visual basic excel
body: <p>I want to Remove Non-Alphanumeric Characters with this Macro. </p>
  
  <p>this simple program gives me a syntax error.</p>
  
  <p>I don't understand this error at all.</p>
  
  <pre><code>Sub CleanAll()
  Dim rng As Range
  Application.ScreenUpdating = False ' Turns off screen updating
  On Error Resume Next ' Macro will continue if it encounters #N/A
  'Adjust "Sheet1" and Range in Line 6
  For Each rng In Sheets("Sheet1").Range("A2:A1629").Cells
      rng.Value = AlphaNumericOnly(rng.Value) ' Function call
  Next
  Application.ScreenUpdating = True
  End Sub
  
  Function AlphaNumericOnly(strSource As String) As String
  Dim i As Integer
  Dim strResult As String
  On Error Resume Next
  For i = 1 To Len(strSource)
  Select Case Asc(Mid(strSource, i, 1))
  'The numbers below match Char Codes to keep
   Case 48 To 57, 65 To 90, 97 To 122:
      strResult = strResult &amp;amp; Mid(strSource, i, 1)
  End Select
  Next
  AlphaNumericOnly = strResult
  End Function
  </code></pre>