|
学习一下
- Sub ykcbf()'筛选 删除行
-
- Dim 编号02_字典
- Dim 编号04_工作表
- Dim 编号05_文件夹路径
- Dim 编号06_标题行数
- Dim 编号07_按第几列拆分
- Dim 编号08_列数
- Dim 编号09_合计在第几行
- Dim 编号10_数组
- Dim 编号11_第几行
- Dim 编号12_字符串
- Dim 编号13_key
- Set 编号02_字典 = CreateObject("scripting.dictionary")
- Set 编号04_工作表 = ThisWorkbook.Sheets("Sheet1")
- 编号05_文件夹路径 = ThisWorkbook.Path & ""
- 编号06_标题行数 = 3
- 编号07_按第几列拆分 = 1
-
- 编号08_列数 = 编号04_工作表.UsedRange.Columns.Count
- 编号09_合计在第几行 = 编号04_工作表.UsedRange.Find("合计").Row
- 编号10_数组 = 编号04_工作表.[a1].Resize(编号09_合计在第几行, 编号08_列数)
- For 编号11_第几行 = 编号06_标题行数 + 1 To UBound(编号10_数组, 1)
- 变量 = 编号10_数组(编号11_第几行, 编号07_按第几列拆分)
- 编号12_字符串 = Trim(变量)
- If 编号12_字符串 <> "" Then
- 编号02_字典(编号12_字符串) = ""
- End If
- Next
-
- For Each 编号13_key In 编号02_字典.keys
- 编号04_工作表.Copy
-
- ActiveWorkbook.Sheets(1).AutoFilterMode = 0
- ActiveWorkbook.Sheets(1).DrawingObjects.Delete
- ActiveWorkbook.Sheets(1).Rows(编号06_标题行数 & ":" & 编号06_标题行数).AutoFilter
- ActiveWorkbook.Sheets(1).Cells(编号06_标题行数, 1).AutoFilter Field:=编号07_按第几列拆分, Criteria1:="<>" & 编号13_key
- ActiveWorkbook.Sheets(1).Cells(编号06_标题行数 + 1, 1).Resize(编号09_合计在第几行).EntireRow.Delete
- ActiveWorkbook.Sheets(1).AutoFilterMode = 0
-
- ActiveWorkbook.SaveAs 编号05_文件夹路径 & 编号13_key
- ActiveWorkbook.Close
- Next
-
- End Sub
复制代码 |
|