|
请教,窗体代码在2016运行出错,无法装载这些对象
Private Sub CheckBox1_Click()
With ListView1
If CheckBox1 = True Then
For I = 1 To .ListItems.Count
.ListItems(I).Checked = True
Next
Else
For I = 1 To .ListItems.Count
.ListItems(I).Checked = False
Next
End If
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Sheets("分项查询").Range("S2:S" & Range("S65500").End(3).Row + 2).ClearContents
With ListView1
For I = 1 To .ListItems.Count
If .ListItems(I).Checked = True Then
Sheets("分项查询").Range("S65536").End(3).Offset(1, 0) = .ListItems(I)
S = S + 1
End If
Next
End With
If CheckBox1 = True Then
Sheets("分项查询").Range("G2") = "全部"
Else
Sheets("分项查询").Range("G2") = S & " 个"
End If
If Sheets("分项查询").Range("S2") = "" Then Sheets("分项查询").Range("G2") = "": MsgBox "你未选择物品!"
Sheets("分项查询").Range("H4").Select
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim ITM As ListItem
With ListView1
.AllowColumnReorder = True
.Sorted = True
.SortKey = 0
.ColumnHeaders.Add 1, , "物品编号", 70
.ColumnHeaders.Add 2, , "物品名称", 80, 2
.ColumnHeaders.Add 3, , "规格型号", 80, 2
.View = lvwReport
.Gridlines = True
.CheckBoxes = True
End With
ARR = Sheets("基础信息表").Range("A2:F" & Sheets("基础信息表").Range("A65500").End(3).Row)
Set D = CreateObject("Scripting.Dictionary")
For I = 1 To UBound(ARR)
If Not D.exists(ARR(I, 1)) Then
Set ITM = ListView1.ListItems.Add()
D.Add ARR(I, 1), ""
ITM.Text = ARR(I, 1)
ITM.SubItems(1) = ARR(I, 2)
ITM.SubItems(2) = ARR(I, 3)
End If
Next I
Set ITM = Nothing
End Sub
|
|