|
发表于 2017-8-15 16:39
|
显示全部楼层
本楼为最佳答案
- Private Sub CommandButton2_Click() '保存
- Dim 批号
- Set d = CreateObject("scripting.dictionary")
- For Each sh In Worksheets
- d(sh.Name) = ""
- Next
- Set lv = ListView1
- For a = 1 To lv.ListItems.Count
- Set itm = lv.ListItems(a)
- 批号 = Left(itm.SubItems(1), 2)
- If Not d.exists(批号) Then
- Sheets.Add after:=Sheets(Sheets.Count)
- ActiveSheet.Name = 批号
- Sheets(1).[a1:d1].Copy Sheets(批号).[a1]
- End If
- Sheets(1).Activate
- With Sheets(批号)
- i = .[a65536].End(3).Row + 1
- .Cells(i, 1) = itm.Text
- .Cells(i, 2) = itm.SubItems(1)
- .Cells(i, 3) = itm.SubItems(2)
- .Cells(i, 4) = itm.SubItems(3)
- End With
- Next a
- End Sub
复制代码 |
|