Prompt to select from a list in another workbook
Try this :
Sub Choose_from_List()
' myForm is your userform containing a list box to select the item
' myList is the list box
zWorkbook = "My Other List.xls" ' being the file containing the list
zListSheet = "My List Sheet" ' being the sheet on which the list is
placed
zListRange = "My List" ' being the list to use
nColumn =
Workbooks(zWorkbook).Worksheets(zListSheet).Range( zListRange).Column
' Ascertain the top row of items to populate the main list
nStart =
Workbooks(zWorkbook).Worksheets(zListSheet).Range( zListRange).Row
' Ascertain the number of items to populate the main list
nItems =
Workbooks(zWorkbook).Worksheets(zListSheet).Range( zListRange).Rows.Count
' Calculate the last row of items to populate the main list
nEnd = nStart + nItems - 1
' Define an array used to hold the items in the list so that it is big
enough to handle the number of items
ReDim myArray(nItems - 1, 2)
For nCount = nStart To nEnd
' Set the array to hold the code of each item in the list
myArray(nCount - nStart, 1) = nCount - nStart + 1
' Set the array to hold the description of each item in the list
myArray(nCount - nStart, 0) =
Workbooks(zWorkbook).Worksheets(zListSheet).Cells( nCount, nColumn)
Next
' Populate the dropdown box list with the available tables
myForm.myList.List = myArray
myForm.Show
End Sub
--
If the post is helpful, please consider donating something to an animal
charity on my behalf.
"Jim G" wrote:
While creating a new service job, I would like users to have a list of jobs
to select from for input into the service registry. The job list resides in
another workbook.
Is it possible to prompt for an input in VBA selected from another sheet or
workbook?
--
Jim
|