我試着運行宏,應清除張AA,BB和CC的內容,然後移動到表菜單,但其highliting我就行4.有誤,請參見下面的代碼。Excel的VBA clearContents中錯誤
Sub clear_sheets()
Snames = Split(AA, BB, CC)
For Count = 0 To UBound(Snames)
Sheets(Snames(Count)).Range("A3:C3").End(xlDown).ClearContents
Next
Sheets("MENU").Select
Optimise (False)
End Sub
我在不同的論壇上發佈了一些不同的方法。哪一個會更有效率地運行,我的意思是哪一個會減輕處理的壓力?
Sub clear_sheets()
Optimise (True)
Snames = Split("AA, BB, CC", ", ")
For count = 0 To UBound(Snames)
MyRange = Range("A3:C3", Range("A3:C3").End(xlDown)).Address
ThisWorkbook.Sheets(Snames(count)).Range(MyRange).ClearContents
Next
Sheets("MENU").Select
Optimise (False)
End Sub
更新 我明白這不是一個代碼編寫的網站,但我想問問你,如果你能有一個看看下面我的代碼。
Sub distribute_dsp_data_9()
Sheets("raw_data_1_9").Visible = True
Sheets("raw_data_1_9").Select
ActiveSheet.ListObjects("COMP_summ_9").Range.AutoFilter Field:=2, Criteria1 _
:="DTTD"
Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Copy
Sheets("DTTD").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("raw_data_1_9").Select
ActiveSheet.ListObjects("COMP_summ_9").Range.AutoFilter Field:=2, Criteria1 _
:="FDTL"
Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Copy
Sheets("FDTL").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("raw_data_1_9").Select
ActiveSheet.ListObjects("COMP_summ_9").Range.AutoFilter Field:=2, Criteria1 _
:="FULL"
Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.Copy
Sheets("FUL ON").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("raw_data_1_9").Select
ActiveSheet.ListObjects("COMP_summ_9").Range.AutoFilter Field:=2
Sheets("raw_data_1_9").Visible = False
末次
你有什麼期望'AA','BB','CC',是?圖紙名稱?這些都沒有聲明,所以VBA假設他們是我認爲的某種變量... – BruceWayne