...我想把listbox1里面我选中的第三项导入到EXCEL里
发布网友
发布时间:2024-10-23 19:07
我来回答
共2个回答
热心网友
时间:2024-10-25 18:53
Private Sub Command1_Click()
List1.Selected(2) = True'选list1里面的中第三行
List1.SetFocus'复制选中行的数据
Dim XlApp As New Excel.Application
Dim XLWorkBook As New Excel.Workbook
Dim XLWorkSheet As New Excel.Worksheet
Set XLWorkBook = XlApp.Workbooks.Add
Set XLWorkSheet = XLWorkBook.Worksheets(1)
XlApp.Visible = True
XLWorkSheet.Cells(2, 1).Value = List1.Text'写入数据
End Sub
Private Sub Form_Load()
List1.AddItem "123456"' '将123456放进list1第一行
List1.AddItem "454678" '将454678放进list1第二行
List1.AddItem "111111"
List1.AddItem "222222"
List1.AddItem "333333"
End Sub
热心网友
时间:2024-10-25 18:46
Private Sub Command1_Click()
List1.Selected(2) = True
List1.SetFocus
Dim XlApp As New Excel.Application
Dim XLWorkBook As New Excel.Workbook
Dim XLWorkSheet As New Excel.Worksheet
Set XLWorkBook = XlApp.Workbooks.Add
Set XLWorkSheet = XLWorkBook.Worksheets(1)
XlApp.Visible = True
XLWorkSheet.Cells(2, 1).Value = List1.Text
End Sub
Private Sub Form_Load()
List1.AddItem "123456"
List1.AddItem "454678"
List1.AddItem "111111"
List1.AddItem "222222"
List1.AddItem "333333"
End Sub