ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   populating multicolumn listbox with an array instead of... (https://www.excelbanter.com/excel-programming/281639-populating-multicolumn-listbox-array-instead.html)

notsureofthatinfo

populating multicolumn listbox with an array instead of...
 
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



All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com