populating multicolumn listbox with an array instead of...

  • Thread starter notsureofthatinfo
  • Start date
N

notsureofthatinfo

I know I am doing this wrong but it gets me close to what I want
because of the way I am dealing with records.

I am inserting my previous post below. Any help please? How should
this be different?


---


This presents everything the way I want, filtering for the State I
want in the form, and I can dump it to a textbox to edit but NOW I see
that storing the edited version will pose problems.

Basically I see that I went about this all wrong because I am lost
when it comes to knowing how to do this with arrays.

This code populates a listbox by first getting the variable it needs
from a clickable map.

Thanks to anyone who can help me understand.

Scott
------

Private Sub UserForm_Initialize()

Dim Contact As String
Dim phone As String
Dim str As String

'pull the State variable from another sub
'to build the listbox contents

UserForm1.Caption = State
ListBox1.ColumnCount = 4
'I want this to be a multicolumn listbox eventually

On Error Resume Next

EntryCount = 1 'to set the starting value

For Each Cell In Sheets("Security").Range("e2:e2000")

'the State is stored in column E

EntryCount = EntryCount + 1 'since the index starts at zero
'and we use the 1st row as a header

Contact = Cell.Offset(0, -4)
phone = Cell.Offset(0, 2)

str = EntryCount & vbTab & State & vbTab & Contact & vbTab & phone
If Cell = State Then ListBox1.AddItem (str) Else


Next Cell
EntryCount = 0
ListBox1.TextColumn = -1


CommandButton1.Caption = "Edit Selection"
CommandButton2.Caption = "Remove Selection"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top