|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Dim dn%
- Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
- 'by bajifeng
- Dim m, n, i
- 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
- 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, k
- 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
复制代码 |
|