我想学习一点VBA。所以我是新手。VBA-Excel循环删除表格的最后一行
我想要一个从第二张到最后一张的循环,然后删除表格中单个表格的最后一行。
目前我有这个代码,我在网上搜索。
Sub ApagaLoop()
'Apaga todas as linhas das tabelas, e percorre todas as folhas.
Dim WS_Count As Integer
Dim I As Integer
Dim sht As Worksheet
Dim LastRow As Long
' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = 7
' Begin the loop.
For I = 2 To WS_Count
' Insert your code here.
Sheets(I).Cells(Rows.Count, 1).End(xlUp).Rows().Select
Rows(ActiveCell.Row).Select
Selection.Delete Shift:=xlUp
' The following line shows how to reference a sheet within
' the loop by displaying the worksheet name in a dialog box.
MsgBox ActiveWorkbook.Worksheets(I).Name
Next I
End Sub
而且我在得到一个错误:
Sheets(I).Cells(Rows.Count, 1).End(xlUp).Row
可有人告诉我,我做错了吗? 非常感谢
你得到了什么错误? – user3598756