Rabu, 22 Februari 2012

[ExcelVBA] Re: LISTBOX

 



--- In ExcelVBA@yahoogroups.com, "JIMNEELY" <jimneely@...> wrote:
>
> I want a listbox to show items from a spreadsheet. The items have to be certain items so I was thinking a FIND would do the trick. but my main question to the group is this possible.
>
This might help. I am trying to fill a listbox with 3 columns based on a one find item. so i look at all "PR0008" and store the 3 columns in a array to later display in a listbox. Here is the code so far. It does not store the "DEPT" but instead the count.
Private Sub UserForm_Initialize()
Dim lb As msforms.ListBox
Dim rcArray() As String
Dim Dept As Integer
With Worksheets("Gages").Range("I2:I25")
Set D = .Find("PR0010", LookIn:=xlValues)
firstaddress = D.Address
Set D = .FindNext(D)
While D.Address <> firstaddress
Dept = Dept + 1
MsgBox Dept
MsgBox D
ReDim Preserve rcArray(1 To Dept)
rcArray(D) = D
Set D = .FindNext(D)
Wend
End With

'Place the array in the listbox
Set lb = Me.ListBox1
With lb
.ColumnCount = 1
.ColumnWidths = "50"
.List = rcArray
End With
End Sub

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar