|
- Dim dn%, lr()
- 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
- Erase lr
- ReDim lr(1 To UBound(s)) '"凭证号码"数组
- 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)
- lr(i) = s(i, 2) '"凭证号码"数组
- Debug.Print lr(i)
- Next i
- End With
- '==============='"凭证号码"数组 验证 开始============
- On Error Resume Next
- Columns(5) = ""
- [e1].Resize(n, 1) = Application.Transpose(lr) '"凭证号码"数组 验证
- '==============='"凭证号码"数组 验证 结束============
- 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
复制代码 |
|