Anybody can help me ?
I need to show the columns with the names (COD, NAME, PHONE) and show the datas,
but in the form, then only show one date (NAME).
In the spreadsheet (clientes) I´ve three columns
A B C
Code Name Phone
Following the code below.
Private Sub UserForm_Activate()
Dim SourceWB As Workbook
Dim ListItems As Variant
Dim i As Integer
Application.ScreenUpdating = False
With Me.ComboBox1
.Clear ' remove existing entries from the combobox
' open the source workbook as ReadOnly
Set SourceWB = Workbooks.Open("C:\TEMP\Clientes.xls", _
False, True)
'no need to use all rows if empty
ListItems.AddItem = SourceWB.Worksheets(1).Range("b2:B50").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
End With
Application.ScreenUpdating = True
End Sub