Populating Comobox with Excel Data.
Hey everyone, the goal is to use a comobox (comobox1) to list data from an excel column.
I have:
Code:
Private Sub repairdone_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Open(My.Computer.FileSystem.SpecialDirectories.Desktop + "\Repairs.xlsx")
oSheet = oBook.worksheets(1)
ComboBox1. '''DUNNO WHAT GOES HERE''' = oSheet.range("A1")
End Sub
Thanks for your help.
Re: Populating Comobox with Excel Data.
To load the values in column A, rows 1 to 5, something like:
Code:
For j = 1 To 5
ComboBox1.Items.Add(oSheet.range("a" & j).value)
Next