iterating an array

  • Thread starter Thread starter Jade
  • Start date Start date
J

Jade

Hi Everyone,

Seeking a bit of help on an issue....I'm running into a tight deadline
on a project and am stuck on how to code an array for a listbox.

Here's the issue. I have Listbox1 which contains several rows and
columns of data. When selected it distributes the values of each
column of row to several textboxes. Once the row has been selected
and the value placed in the textboxes, a lookup must be completed that
would extract from Listbox1 (or its array) each row that contains that
value in the textbox. Each row containing that value will be placed in
Listbox2. I realize it requires an iteration of the array in Listbox1
with an if..then / for ...next code structure but I'm stuck ...whether
i've been looking at this thing for too long or its lack of
sleep...I'm clearly stuck.....any help would be greatly appreciated

here's my code for listbox1:

Set rg = objXL.worksheets(1).Range("A1:d17")
Call RangeToArray(rg, arr)
Set ListBox1 = Item.GetInspector.ModifiedFormPages("pg.
2").Controls("ListBox1")
ListBox1.List = arr
End Sub

Thanks...!!!
 
Assuming, you have an array with three rows and two columns, that could look
like this:

Dim arr(2, 1)
Dim Row&, Col&

For Row=0 To UBound(arr, 1)
For Col=0 To UBound(arr, 2)
If arr(Row, Col)="whatever" Then
' match, add Row to your listbox
' don't check more cols of this row
Exit For
Endif
Next Col
Next Row

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Tue, 8 Jul 2008 20:28:29 -0700 (PDT) schrieb Jade:
 
Back
Top