|
本帖最后由 cmo9020 于 2022-12-23 10:07 编辑
ListView2.rar
(26.69 KB, 下载次数: 16)
各位大神导师晚上好....
请问一下,listview1打勾框要怎么样弄成一行
(像图二一样)
勾选后,要填入C行单元格内,目前只有显示 " , "
需要修改哪些地方,搞不定....请帮忙一下,谢谢导师们
图二↓
Dim arr
Private Sub CommandButton1_Click()
Dim sd As String, y As Long, j As Long
With ListView1.ListItems
y = .Count
If y = 0 Then
MsgBox "No items were selected!"
Exit Sub
End If
j = 1
For x = 1 To y
If .Item(x).Checked = True Then
If j = 1 Then
sd = .Item(x).SubItems(1)
Else
sd = sd & "," & .Item(x).SubItems(1)
End If
j = j + 1
End If
Next
End With
ActiveCell = sd
Unload Me
End Sub
Private Sub UserForm_Initialize()
arr = Sheet2.Range("c1").CurrentRegion
For i = 1 To UBound(arr, 2)
ComboBox1.AddItem arr(1, i)
Next
With ListView1
.ColumnHeaders.Clear
.ListItems.Clear
.ColumnHeaders.Add 1, , "", .Width / 3
.ColumnHeaders.Add 2, , "", .Width / 0.57
.View = lvwReport
.Gridlines = True
.FullRowSelect = True
.MultiSelect = True
End With
End Sub
Private Sub ComboBox1_Change()
s = Me.ComboBox1.Text
Me.ListView1.ListItems.Clear
If Len(s) Then
For i = 1 To UBound(arr, 2)
If arr(1, i) = s Then
For j = 2 To UBound(arr)
If Len(arr(j, i)) Then Me.ListView1.ListItems.Add.Text = arr(j, i)
Next
Exit For
End If
Next
End If
End Sub
|
|