|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 cmo9020 于 2022-12-21 17:06 编辑
请问导师们一下,在没有选择listview内容时
CommandButton1执行确定,原本在单元格有数据,变成会消失
请问需要修改什么地方,
在没有选择listview内容时候按下执行数据不会消失,谢谢导师指导一下,谢谢
Private Sub CommandButton1_Click()
With ListView1.ListItems
y = .Count
If y = 0 Then
Unload Me
Exit Sub
End If
Dim x As Integer
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(x)
End If
j = j + 1
End If
Next
End With
ActiveCell = sd
Unload Me
End Sub
Private Sub UserForm_Initialize()
With ListView1
.ColumnHeaders.Clear
.ListItems.Clear
.ColumnHeaders.Add 1, , "", .Width / 16
.ColumnHeaders.Add 2, , "", .Width / 6
.ColumnHeaders.Add 3, , "", .Width / 1
.View = lvwReport
.Gridlines = True
.FullRowSelect = True
.MultiSelect = True
End With
rw = Sheet3.Range("a65536").End(xlUp).Row
rw = Sheet3.Range("q65536").End(xlUp).Row
For i = 1 To rw
Set xitem = ListView1.ListItems.Add
xitem.SubItems(1) = Sheet3.Cells(i, 1)
xitem.SubItems(2) = Sheet3.Cells(i, 17)
Next
End Sub |
|