Results 1 to 2 of 2

Thread: Populating Comobox with Excel Data.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    123

    Question 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.
    VS 2017 - Need as much help as you can give (write it all for me!)

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width