visual basic excel中的基本语法错误

时间:2015-12-09 16:51:54

标签: excel excel-vba vba

我想用此宏删除非字母数字字符。

这个简单的程序给我一个语法错误。

我根本不理解这个错误。

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 & Mid(strSource, i, 1)
End Select
Next
AlphaNumericOnly = strResult
End Function

1 个答案:

答案 0 :(得分:1)

您的var allTextNodes = $('*').contents().filter(function() { return this.nodeType == Node.TEXT_NODE; }); 语法无效。将其更改为:

&