|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Dim dn%, k
- Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
- 'by bajifeng
- ReDim s(1 To dn, 1 To 2)
- For Each ck In ListView1.ListItems
- m = m + 1
- If ck.Checked Then
- n = n + 1
- s(n, 1) = n
- s(n, 2) = ListView1.ListItems(m)
- End If
- Next
- With ListView2
- .ListItems.Clear
- .ColumnHeaders.Add , , "序号", 30
- .ColumnHeaders.Add , , "凭证号码", 50
- .View = lvwReport
- .FullRowSelect = True
- .Gridlines = True
- For i = 1 To UBound(s)
- Set Itm = .ListItems.Add()
- Itm.Text = s(i, 1)
- Itm.SubItems(1) = s(i, 2)
- Next i
- End With
- End Sub
- Private Sub UserForm_Initialize()
- Dim arr, a, d, i, t
- Set d = CreateObject("scripting.dictionary")
- With Sheets("sheet1")
- a = .Range("D2").End(xlDown).Row
- arr = .Range("D2:D" & a)
- For i = 2 To UBound(arr)
- d(arr(i, 1)) = ""
- Next i
- k = d.keys
- t = d.items
- dn = d.Count
- End With
- With ListView1
- Dim Itm
- .ListItems.Clear
- .ColumnHeaders.Add , , "凭证号码", 50
- .View = lvwReport
- .FullRowSelect = True
- .Gridlines = True
- .MultiSelect = True
- .CheckBoxes = True
- For i = 0 To UBound(k)
- Set Itm = .ListItems.Add()
- Itm.Text = k(i)
- Next i
- End With
- With ListView2
- .ListItems.Clear
- .ColumnHeaders.Add , , "序号", 30
- .ColumnHeaders.Add , , "凭证号码", 50
- .View = lvwReport
- .FullRowSelect = True
- .Gridlines = True
- End With
- End Sub
复制代码 |
|