|
- Dim AR, R1&, a&, S1 As Range, n As String, sh As Worksheet
- Sub auto_open()
-
- Dim mCaidan As Menu
- MenuBars(xlWorksheet).Reset
- Set mCaidan = MenuBars(xlWorksheet).Menus.Add("system")
- With mCaidan.MenuItems
- .Add "循环工作表", "循环工作表"
- End With
- End Sub
- Sub 循环工作表()
- On Error Resume Next
- n$ = ActiveWorkbook.Name
- n = Sheets("客户名称").[a1].Value
- For Each sh In Workbooks("n$").Sheets
- If sh.Name <> "客户名称" Then
- sh.Activate
- Call 删除指定内容(sh)
- End If
- Next
- End Sub
- Sub 删除指定内容(sh)
- R1 = sh.Cells(sh.Rows.Count, 2).End(xlUp).Row
- AR = sh.Cells(1, 2).Resize(R1)
- For a = 5 To R1
- If AR(a, 1) <> n Then
- If S1 Is Nothing Then
- Set S1 = sh.Rows(a).EntireRow
- Else
- Set S1 = Union(S1, sh.Rows(a).EntireRow)
- End If
- End If
- Next
- If Not S1 Is Nothing Then S1.Delete: Set S1 = Nothing
- sh.[a1].Select
- End Sub
复制代码 |
|