LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Select all data in column and list in form combo box

I'm having a spot of trouble with the following code, I would like to
list all the records in column A I tried to do the following,
ListItems = SourceWB.Worksheets(1).Range(.Range("A2"), _
.Range("A65536").End(xlUp)).Value
to select all the records in column A but it doesn't work, any idea
why.

Once I've selected the record of choice from the combo box, would it be
relatively easy to look at the same row in the source workbook, but
offset 1 column (column B) and depending upon it's data do a Do Case
for further processing.

For example lets say that column A contains part numbers, the part
numbers will be populated into the combo box, once I select the part
number of choice from the combo box, I want to look at the
corresponding row but offset 1 column (column B). In column B would be
product types, now depending upon the product type I would likely do a
Do Case to run further processing.

Private Sub UserForm_Initialize()
Dim ListItems As Variant, i As Integer
Dim SourceWB As Workbook

With Me.ComboBox1
.Clear ' remove existing entries from the combobox
' turn screen updating off,
' prevent the user from seeing the source workbook being opened
Application.ScreenUpdating = False
' open the source workbook as ReadOnly
Set SourceWB = Workbooks.Open("C:\Folder Name\Source
Workbook.xls", _
False, True)

ListItems = SourceWB.Worksheets(1).Range("A1:A5").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
For i = 1 To UBound(ListItems)
.AddItem ListItems(i) ' populate the listbox
Next i
.ListIndex = -1 ' no items selected, set to 0 to select the
first item
Application.ScreenUpdating = True
End With
End Sub

Thanks
burl_rfc

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
select macro within combo box or list box to Karin Excel Discussion (Misc queries) 2 June 25th 08 01:49 AM
How do you get outlook to select from list on a form gbpg Excel Discussion (Misc queries) 1 August 27th 07 05:54 PM
Select Row in List Box with 2 columns - Col 1 populates form 1 box1,Col 2 pop box2 [email protected] Excel Programming 2 March 21st 06 01:00 AM
list related files, select which to open form Sami82[_5_] Excel Programming 0 September 14th 05 05:38 AM
a data entry form with combo box xcao Excel Discussion (Misc queries) 4 June 25th 05 05:37 AM


All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"