Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-21-2015, 04:46 AM
VBA-User VBA-User is offline Excel Combobox List Windows 7 64bit Excel Combobox List Office 2013
Novice
Excel Combobox List
 
Join Date: Dec 2015
Posts: 5
VBA-User is on a distinguished road
Default Excel Combobox List

Hello,

I try to fill a combobox with Text from an excelsheet. The code i wrote works fine, but when i select my combobox a second time, then the entries will appear a second time in my combobox and after clicking a third time on the arrow to open it, all entries are three times there and so on. I am not using an userform, i have inserted the an activeX element for combobox in the excel sheet from Developer tools. Here is the code:

Private Sub ComboBox2_Change()

Dim WS As Worksheet
Dim LastRow As Long
Dim aCell As Range
Dim lIndxA As Long
Dim lIndxI As Long
Dim sTemp As String

ComboBox2.Clear

Call FillCombobox("List", "B", Me.ComboBox2)

Set WS = ActiveWorkbook.Worksheets("List")

With WS
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row

For Each aCell In .Range("B2:B500" & LastRow)
If aCell.Value <> "" Then
Me.ComboBox2.AddItem aCell.Value
End If
Next

For lIndxA = 0 To Me.ComboBox2.ListCount - 1
For lIndxI = 0 To lIndxA - 1
If Me.ComboBox2.List(lIndxI) > Me.ComboBox2.List(lIndxA) Then
sTemp = Me.ComboBox2.List(lIndxI)
Me.ComboBox2.List(lIndxI) = Me.ComboBox2.List(lIndxA)
Me.ComboBox2.List(lIndxA) = sTemp
End If
Next lIndxI
Next lIndxA



End With

End Sub

I hope someone can help me.

regards
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Combobox List Using combobox to pass data from an Excel spread sheet to text boxes on userform Stewie840 Word VBA 14 12-17-2015 10:13 PM
Excel Combobox List combobox list gets reset....please help Deepa Shrestha Word VBA 1 09-29-2013 09:30 PM
Excel Combobox List VB code: populate combobox from columns in Excel file billybeach Outlook 2 04-27-2013 04:38 AM
Excel Combobox List Adding a long list of values to a combobox in Word 2003? ll4u76 Word VBA 1 04-13-2012 03:37 AM
Excel Combobox List Populating ComboBox or Drop Down list with contents of a text field Billy_McSkintos Word VBA 1 09-13-2011 05:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft