我有一个函数Sub fRemoveCharList(ColArray As Variant, char As Variant)
(下面的代码)来删除w.r.t标题列表中的字符列表。
如果我打电话给...
Sub RemoveCharList()
fRemoveCharList Array("field1","field2","field3"), Array("]", "&", "%")
End Sub
......工作正常
但如果我改为......
Call fRemoveCharList(("field1","field2","field3"), ("]","&","%"))
...这是我的首选方式,我收到“类型不匹配”错误。我需要有一个数组数组才能像这样使用它吗?
我已经用谷歌搜索了如何继续,但发现我无法使用。
功能:
Sub fRemoveCharList(ColArray As Variant, char As Variant)
Dim x As Variant
Dim LR As Long, i As Long, j As Long
Dim Heading As Variant
Dim headingFound As Range
Dim lngColIndex As Long
For Each Heading In ColArray
On Error Resume Next
Set headingFound = Range("1:1").Find(What:=Heading, LookIn:=xlFormulas, LookAt:=xlPart)
Err.Clear: On Error GoTo 0: On Error GoTo -1
If Not headingFound Is Nothing Then lngColIndex = headingFound.Column
LR = Cells(Rows.Count, lngColIndex).End(xlUp).Row
For i = 1 To LR
With Cells(i, lngColIndex)
x = .Value
For j = LBound(char) To UBound(char)
x = Replace(x, char(j), vbNullString)
Next
.Value = x
End With
Next i
Next
End Sub
答案 0 :(得分:1)
尝试以下任一方式:
Run fRemoveCharList Array("field1","field2","field3"), Array("]", "&", "%")
或者:
Call fRemoveCharList(Array("field1","field2","field3"), Array("]","&","%"))