Thread: listbox list
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default listbox list

I created a listbox on a userform and used this code:

Option Explicit
Private Sub UserForm_Initialize()

Dim myCell As Range
Dim myRng As Range
Dim myWord As String

myWord = "total"

With Worksheets("Sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each myCell In myRng.Cells
If LCase(Left(myCell.Value, Len(myWord))) = LCase(myWord) Then
Me.ListBox1.AddItem myCell.Value
End If
Next myCell

End Sub


You may want to look at some code that John Walkenbach has shared:
http://j-walk.com/ss/excel/tips/tip47.htm

You may want to incorporate some of the stuff he did (unique entries and
sorting).

tjh wrote:

Hello,

I would like to create a list in a listbox on an Excel Form, based values in
column A that start with the word "Total." Is it possible to reference such a
list. Please let me know if I need to give more detail.

Thank You


--

Dave Peterson