我想基于过滤器从Excel中删除数据。根据工作表名称(具有指定的列A列)过滤数据,并删除“隐藏”值。
我打算根据工作表名称保留数据,我尝试使用循环,但处理时间很长。
App\Admin\ParentAdmin:
calls:
- [addChild, ['@App\Admin\ChildAdmin', 'parent']]
App\Admin\GrandParentAdmin:
calls:
- [addChild, ['@App\Admin\ParentAdmin', 'grandParent']]
答案 0 :(得分:0)
您可以修改并尝试以下解决方案:
Option Explicit
Sub test()
Dim ws As Worksheet
Dim LastRow As Long, Index As Long, j As Long
Dim newtemp As String
For Each ws In ThisWorkbook.Worksheets
Index = Index + 1
With ws
If Index <= 10 Then
newtemp = Replace(.Name, " ", "#0")
Else
newtemp = Replace(.Name, " ", "#")
End If
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For j = LastRow To 2 Step -1
If .Cells(j, 1) <> newtemp Then
.Rows(j).EntireRow.Delete
End If
Next j
End With
Next ws
MsgBox ("Deleted")
End Sub