V
vbRookie07
can someone help me modify this code so that my combobox filters out
duplicate values?
Private Sub UserForm_Initialize()
Dim ListStates As Variant, i As Integer
Dim SourceWB As Workbook
With Me.cboState
.Clear ' remove existing entries from the listbox
' turn screen updating off,
' prevent seeing source workbook being opened
Application.ScreenUpdating = False
' open source workbook as ReadOnly
Set SourceWB = Workbooks.Open("H:\Project Tracking db\FY08 Per
Diem Rates.xls", _
False, True)
ListStates = SourceWB.Worksheets(1).Range("A4:A666").Value
' get values
SourceWB.Close False ' close source workbook without saving
Set SourceWB = Nothing
ListStates =
Application.WorksheetFunction.Transpose(ListStates)
' convert values to a vertical array
For i = 1 To UBound(ListStates)
.AddItem ListStates(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
duplicate values?
Private Sub UserForm_Initialize()
Dim ListStates As Variant, i As Integer
Dim SourceWB As Workbook
With Me.cboState
.Clear ' remove existing entries from the listbox
' turn screen updating off,
' prevent seeing source workbook being opened
Application.ScreenUpdating = False
' open source workbook as ReadOnly
Set SourceWB = Workbooks.Open("H:\Project Tracking db\FY08 Per
Diem Rates.xls", _
False, True)
ListStates = SourceWB.Worksheets(1).Range("A4:A666").Value
' get values
SourceWB.Close False ' close source workbook without saving
Set SourceWB = Nothing
ListStates =
Application.WorksheetFunction.Transpose(ListStates)
' convert values to a vertical array
For i = 1 To UBound(ListStates)
.AddItem ListStates(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