Solved

vba: How to fill in combobox in excell from sheet ?

Posted on 2001-09-18
2
177 Views
Last Modified: 2012-05-04
I have a sheet with a list of variables.   How can i fill in this combo box with necessary inforatmion because the number of item  can change with the time.
For example:


LOLO
LILI
LALA
[Empty]
[Empty]
......
......
......

I like have just LOLO LILI LALA
0
Comment
Question by:zoltix
  • 2
2 Comments
 
LVL 6

Expert Comment

by:OlegP
ID: 6489936
Public Sub FillMy(ByRef cb As ComboBox, st As String)
Dim I As Long
Dim b As Long
Dim c As String
If (Len(RTrim(LTrim(st))) = 0) Then Exit Sub
Do
 st = LTrim(RTrim(st))
 b = InStr(1, st, " ")
 If (b <> 0) Then
    c = Mid(st, 1, b - 1)
    st = Mid(st, b, Len(st) - b + 1)
   Else
    c = st
 End If
 cb.AddItem c
Loop While b <> 0
End Sub
0
 
LVL 6

Accepted Solution

by:
OlegP earned 50 total points
ID: 6489937
Public Sub FillMy(ByRef cb As ComboBox, st As String)
Dim I As Long
Dim b As Long
Dim c As String
If (Len(RTrim(LTrim(st))) = 0) Then Exit Sub
Do
 st = LTrim(RTrim(st))
 b = InStr(1, st, " ")
 If (b <> 0) Then
    c = Mid(st, 1, b - 1)
    st = Mid(st, b, Len(st) - b + 1)
   Else
    c = st
 End If
 cb.AddItem c
Loop While b <> 0
End Sub
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now