私が使用する新しいバージョンのマクロ (より高速にするためのトリング) は、新しい (元の) ワークブックで実行されますが、
私の「作業中の」ワークブック (他のマクロを含む) では、マクロを実行した場合にのみ新しいマクロが実行されoriginal
ます
ona フィールドの後に新しいマクロを実行すると、任意のフィールドで機能します。
または、WB を閉じてから開き、新しいマクロを実行すると、新しいマクロが "Working" ワークブックで機能します。
これは、このように動作する唯一のマクロです。
誰かがこれが新しいマクロの問題なのか、それとも私の「作業中」のワークブックに隠れた問題や競合があるのか を確認できますか
ありがとう
Sub RemoveCharList()
fRemoveCharList Array("field2", "field4", "field5", "field7"), Array("]", "&", "%")
End Sub
新しいマクロ
Sub fRemoveCharList(ColArray As Variant, char As Variant)
Dim j As Long, Heading As Variant, headingFound As Range
For Each Heading In ColArray
Set headingFound = Range("1:1").Find(What:=Heading)
If Not headingFound Is Nothing Then
With Range(headingFound, Cells(Rows.Count, headingFound.Column).End(xlUp))
For j = LBound(char) To UBound(char)
.Replace char(j), vbNullString
Next
End With
End If
Next
End Sub
元のマクロ
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
'If headingFound.Column 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