Так выводит только последний выбранные элемент, но столько раз сколько элементов в списке я выбрал. [vba]
Код
Private Sub CommandButton1_Click() Dim iRow&: iRow = ListBox1.ListIndex For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) Then If iRow = -1 Then Exit Sub With wsSheet5.Cells(wsSheet5.Rows.Count, "E").End(xlUp) .Cells(2, -2).Resize(, 4) = Application.Index(ListBox1.List, iRow + 1, 0)
.Cells(2, -3) = wsSheet1.Name .CurrentRegion.Borders.LineStyle = xlContinuous End With End If Next i ' MsgBox ListBox1.List(iRow, 2), , "Добавлено :" Unload Me 'Me.Hide End Sub
[/vba]
Так выводит только последний выбранные элемент, но столько раз сколько элементов в списке я выбрал. [vba]
Код
Private Sub CommandButton1_Click() Dim iRow&: iRow = ListBox1.ListIndex For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) Then If iRow = -1 Then Exit Sub With wsSheet5.Cells(wsSheet5.Rows.Count, "E").End(xlUp) .Cells(2, -2).Resize(, 4) = Application.Index(ListBox1.List, iRow + 1, 0)
.Cells(2, -3) = wsSheet1.Name .CurrentRegion.Borders.LineStyle = xlContinuous End With End If Next i ' MsgBox ListBox1.List(iRow, 2), , "Добавлено :" Unload Me 'Me.Hide End Sub