各位大大,
之前有請教大家使用下列語法可以刪除指定字元
For Each x In Split("TPD.TPD-both.TPD-viewing.GSA", ".")
我想把這一段改成刪除 類別: 以及 會計科目:
我改成
For Each x In Split("類別:"."會計科目:", ".")
但出現錯誤
是否語法須修訂
Sub Step1()
Dim d As Object
Dim arr
st = Timer
Set d = CreateObject("Scripting.Dictionary")
For Each x In Split("TPD.TPD-both.TPD-viewing.GSA", ".")
d(x) = ""
Next x
arr = Range("A1:A" & ActiveSheet.UsedRange.Rows.Count)
For I = 1 To UBound(arr)
If d.exists(arr(I, 1)) Then arr(I, 1) = ""
Next I
[A1].Resize(UBound(arr), 1) = arr
Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Set d = Nothing
arr = ""
End Sub作者: bobomi 時間: 2017-3-2 17:59
懶羊羊你好
For Each x In Split("類別:.會計科目:", ".")作者: jsc0518 時間: 2017-3-2 19:06
Sub DelBlank2()
Dim d As Object
Dim arr
st = Timer
Set d = CreateObject("Scripting.Dictionary")
For Each x In Split("類別:.會計科目:", ".")
d(x) = ""
Next x
arr = Range("A1:A" & ActiveSheet.UsedRange.Rows.Count)
For I = 1 To UBound(arr)
If d.exists(arr(I, 1)) Then arr(I, 1) = ""
Next I
[A1].Resize(UBound(arr), 1) = arr
Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Set d = Nothing
arr = ""
End Sub作者: bobomi 時間: 2017-3-2 23:57
Sub DelBlank2()
Dim d As Object
Dim arr
st = Timer
Set d = CreateObject("Scripting.Dictionary")
For Each x In Split("類別:.會計科目:", ".")
d(x) = ""
Next x
arr = Range("A1:A" & ActiveSheet.UsedRange.Rows.Count + 1)
For I = 1 To UBound(arr)
If d.exists(arr(I, 1)) Then arr(I, 1) = ""
Next I
[A1].Resize(UBound(arr), 1) = arr
Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Set d = Nothing
arr = ""
End Sub作者: jsc0518 時間: 2017-3-3 08:31
那就做區域吧!(with)
With Sheets("工作表")
arr = .Range("A1:A" & .UsedRange.Rows.Count + 1)
For I = 1 To UBound(arr)
If d.exists(arr(I, 1)) Then arr(I, 1) = ""
Next I
.[A1].Resize(UBound(arr), 1) = arr
.Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With作者: jsc0518 時間: 2017-3-5 06:49