我有这个查询删除除第一行之外的所有工作表中的所有数据。我想在每个工作表上激活单元格“A2”,但不能完全理解它。有什么想法吗?
Sub ClearWorkbook()
Dim Current As Worksheet
For Each Current In Worksheets
Current.Rows("2:" & Rows.Count).ClearContents
Next
End Sub
答案 0 :(得分:3)
总结评论:
Sub ClearWorkbook()
Dim Current As Worksheet
For Each Current In Worksheets
If Current.Cells(Current.Rows.Count, "A").End(xlUp).Row >= 2 Then
Current.Rows("2:" & Current.Cells(Current.Rows.Count, "A").End(xlUp).Row).ClearContents
End If
Current.Activate
Current.Range("A2").Select
Next
End Sub