0
下面的代碼旨在將字符串轉換爲一個工作表中的簡潔數組,但它不斷更改工作簿中其他工作表中的文本。Excel VBA:將腳本隔離到一個工作表
我已經突出顯示了我認爲問題出現的地方,其中包含評論#below
和#above
。
我怎樣才能使這個運行在指定的表格上?
Sub Convert()
Rows(2).EntireRow.Hidden = True
Rows(3).EntireRow.Hidden = True
Rows(4).EntireRow.Hidden = True
Rows(5).EntireRow.Hidden = True
'##Below
Dim sht As Worksheet
Dim fndList As Variant
Dim rplcList As Variant
Dim x As Long
fndList = Array(" CR 0.00 0.00 ", " DR 0.00 0.00 ", " 0.00 ", " Cr", " Dr", "0.00", "0.00 ")
rplcList = Array(";-", ";", ";", "", "", "", "")
For x = LBound(fndList) To UBound(fndList)
For Each sht In ActiveWorkbook.Worksheets
sht.Cells.Replace What:=fndList(x), Replacement:=rplcList(x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next sht
'##Above
Next x
Range("A1") = "Account"
Range("C1") = "Balance"
Range("D1") = "KP"
Range("A2", Range("A2").End(xlDown)).TextToColumns _
Destination:=Range("A2"), DataType:=xlDelimited, Semicolon:=True
Columns("B:C").AutoFit
Range("A1", Range("A1").End(xlDown)).Copy
Range("C1", Range("C1").End(xlToRight).End(xlDown)).PasteSpecial _
Paste:=xlPasteFormats
Application.CutCopyMode = False
Columns(2).EntireColumn.Hidden = True
Range("C:C").AutoFilter 1, "<>", , , False
End Sub
@ YowE3K這幾乎是8:00 AM –
@ YowE3K我有小孩,我每天早晨跑,我每天醒來,在04:30 :( –
非常感謝曬!我等不及要試試這個了 - 我會告訴你明天它會怎麼樣! –