[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

2 column List Box populated with data not from Excel sheet?

MariahJ

12/11/2006 4:53:00 PM

Hello,

I would like to populate a listbox with 2 columns of data. This data is
in an array called FirmNames. This is how I am doing it currently

With FirmList
For i = 1 To NumFirmNames
.AddItem (CStr(FirmNames(i).FirmName & vbTab &
FirmNames(i).Selected))
Next i
End With

However, the problem is that the FirmNames have different lengths, so
the second column does not line up.

I am much more familiar with forms in Access, and would like to do
something similar to the following:

For i = 1 To NumFirmNames
rowString = rowString & CStr(FirmNames(i).FirmName) &
"; " & FirmNames(i).Selected & "; "
Next i
FirmList.RowSource = rowString

(The column count property is set to 2). However, this gives me a
syntax error in Excel because the rowSource property here seems to be a
range on the Excel worksheet.

Any help would be greatly appreciated.

Thanks,
Mariah

1 Answer

MariahJ

12/11/2006 6:44:00 PM

0

I have the column widths set. The problem is I don't know how to get
the data into 2 different columns. What I am doing now puts both
FirmNames(i).FirmName and FirmName(i).Selected into the same column.

JLGWhiz wrote:
> You can set the column width with the ColumnWidths Property. See VBA Help
> for details.
>
> "MariahJ" wrote:
>
> > Hello,
> >
> > I would like to populate a listbox with 2 columns of data. This data is
> > in an array called FirmNames. This is how I am doing it currently
> >
> > With FirmList
> > For i = 1 To NumFirmNames
> > .AddItem (CStr(FirmNames(i).FirmName & vbTab &
> > FirmNames(i).Selected))
> > Next i
> > End With
> >
> > However, the problem is that the FirmNames have different lengths, so
> > the second column does not line up.
> >
> > I am much more familiar with forms in Access, and would like to do
> > something similar to the following:
> >
> > For i = 1 To NumFirmNames
> > rowString = rowString & CStr(FirmNames(i).FirmName) &
> > "; " & FirmNames(i).Selected & "; "
> > Next i
> > FirmList.RowSource = rowString
> >
> > (The column count property is set to 2). However, this gives me a
> > syntax error in Excel because the rowSource property here seems to be a
> > range on the Excel worksheet.
> >
> > Any help would be greatly appreciated.
> >
> > Thanks,
> > Mariah
> >
> >