Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to create code that will populate a combo box from an external
file. I am stumped why I am receiving an out of script error and basically why my code isnt working. Could someone please tell me what I am doing wrong? Private Sub CommandButton1_Click() Dim rowInx, numRows As Long Dim MyArray() As String 'Set ComboxBox properties ** ComboBox1.BoundColumn = 1 ComboBox1.ColumnCount = 3 ComboBox1.ColumnWidths = "50 pt" & ";" & "200pt" & ";" & "50pt" ComboBox1.ColumnHeads = True ComboBox1.ListWidth = 325 ComboBox1.LinkedCell = "A6" 'this worksheet is 20 columns wide and at least 25 rows and is updated daily ** 'only the first 3 columns is needed to be displayed in the combobox ** Workbooks.Open Filename:="c:\CCF\Contracts1.xls" With ThisWorkbook.Worksheets("Sheet1") 'Determine number of rows ** numRows = Application.CountA(ActiveSheet.Range("A:A")) 'Clear Listindexes ** ComboBox1.Clear 'Refresh listindexes with current data ** 'the combobox should display 3 columns to the user ** 'the combobox is embedded on a worksheet, not a userform ** For rowInx = 1 To numRows MyArray(rowInx, 0) = ActiveSheet.Cells(1, (rowInx + 1)).Value MyArray(rowInx, 1) = ActiveSheet.Cells(1, (rowInx + 1)).Value MyArray(rowInx, 2) = ActiveSheet.Cells(1, (rowInx + 1)).Value Next rowInx 'Load data into combobox *** ComboBox1.Column() = MyArray ComboBox1.ListIndex = 0 End With ActiveWorkbook.Close End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
multicolumn adress file. want to sort on last , first name | New Users to Excel | |||
Transferring items between multicolumn listboxes | Excel Discussion (Misc queries) | |||
Populating multicolumn listbox the wrong way | Excel Programming | |||
multicolumn Listbox and textalignment | Excel Programming | |||
Values in a MultiColumn Listbox | Excel Programming |