我有下面的代码,并且不断出现运行时错误438,有人可以帮助我调试吗?谢谢!
Sub my sub ()
Dim wb As Workbook
Set wb = Workbooks.Open(link to file)
Dim ws As Worksheet
For Each ws In wb
ws.Cells.ClearContents
Next
End Sub
答案 0 :(得分:-1)
尝试:
Option Explicit
Sub Test()
Dim ws As Worksheet
'Loop all sheet in the workbook
For Each ws In ThisWorkbook.Worksheets
'Clear the used range of the sheet
ws.UsedRange.Clear 'or .ClearContents
Next ws
End Sub