|
简单修改下
Private Sub ListBox1_Change()
Dim i As Long, strMy As String
With ListBox1
'If .Selected(0) = True Then .Selected(0) = False
'如果用户选取的是标题行那么撤销选取
For i = 0 To .ListCount - 1
'遍历listbox的记录,如果被选中则按换行符合并
If .Selected(i) = True Then
temp1 = "、" & .List(0, 0)
temp2 = "、" & .List(1, 0)
strMy = strMy & "、" & .List(i, 0)
strMy2 = strMy2 & "、" & .List(i, 1)
'取list的第二列
'无论列还是行的索引都是从0开始的,因此第二列为1
End If
Next
End With
ActiveCell.Value = Replace(Replace(Mid(strMy, 2), temp1, ""), temp2, "")
ActiveCell(1, 2) = Mid(strMy2, 2)
'数据写入单元格
End Sub
|
评分
-
1
查看全部评分
-
|