Hi All
I'm back begging for help again.
Keep getting run-time error message when i get to the "convert values to a vertical array" part below in Red.
Can anybody see where i'm going wrong please. it should be making a list of request numbers for a combobox in a userform so i can update existing records but having many troubles with my first plan to get a list of request numbers which i can then use to populate other things with a vlook or similar.
Worksheets("datastore") = the tab in my book
Range("datastable[RqNo]") = the table in my tab with RqNo being the table column name
I'm back begging for help again.
Keep getting run-time error message when i get to the "convert values to a vertical array" part below in Red.
Can anybody see where i'm going wrong please. it should be making a list of request numbers for a combobox in a userform so i can update existing records but having many troubles with my first plan to get a list of request numbers which i can then use to populate other things with a vlook or similar.
Worksheets("datastore") = the tab in my book
Range("datastable[RqNo]") = the table in my tab with RqNo being the table column name
Code:
Option Explicit
Sub populate_reqNo_combo()
Dim SourceWB As Workbook
Dim ListItems As Variant
Dim i As Integer
Application.ScreenUpdating = False
With FrmUpdateRequest.cmbFindReqUR
.Clear ' remove existing entries from the combobox
' open the source workbook as ReadOnly
Set SourceWB = Workbooks.Open(myfilepath\myfilename, _
False, True)
'no need to use all rows if empty
ListItems = SourceWB.Worksheets("datastore").Range("datastable[RqNo]").End(xlUp).Value
' get the values you want
SourceWB.Close False ' close the source workbook without saving changes
Set SourceWB = Nothing
ListItems = Application.WorksheetFunction.Transpose(ListItems)
' convert values to a vertical array
[COLOR=#ff0000][B] For i = 1 To UBound(ListItems)[/B][/COLOR]
.AddItem ListItems(i) ' populate the listbox
Next i
.ListIndex = -1 ' no items selected, set to 0 to select the first item
End With
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: