Private Sub ListBox1_Change()
Dim AA(), xi As Integer
With ListBox1
For xi = 0 To .ListCount - 1
If .Selected(xi) = True Then
AA = Application.Index(ListBox1.List, xi + 1)
' 陣列中抽出指定的元素陣列(這裡是一維陣列)
TextBox2.Value = AA(1)
TextBox3.Value = AA(2)
TextBox4.Value = AA(3)
TextBox5.Value = AA(5)
comEnable TextBox5.Value, IIf(TextBox5.Value = "DA", True, False)
End If
Next
End With
End Sub作者: lpk187 時間: 2016-8-9 17:21
Private Sub CommandButton1_Click()
Dim AA(), xi As Integer
With ListBox1
For xi = 0 To .ListCount - 1
' 判斷列表框 (ListBox1) 是否有被點選
If .Selected(xi) = True Then
' 取出該行之數據,存入 AA 陣列中
AA = Application.Index(ListBox1.List, xi + 1)
Range("A1").Select
Selection.End(xlUp).Select
Sheets("sheet1").Range("a" & ActiveCell.Row + 1) = AA
Exit For
End If
Next
End With