|
-
Jun 6th, 2006, 03:09 AM
#1
Thread Starter
New Member
Creating MultiColumns ListBox from VBA array
Hi,
I'm trying to create a listbox regarding to a VBA "virtual" array I have.
for example:
Dim MyArray(3, 3)
For i = 1 To 3
For k = 1 To 3
MyArray(i, k) = i & k
Next
Next
Now, I want to enter the data to a multicolumn listbox (3 X 3) but don't know how.
Help?
-
Jun 6th, 2006, 06:08 AM
#2
Re: Creating MultiColumns ListBox from VBA array
Simple way - works until you get lots of data...
set the list box to values, the column count to 3
then create a string using your loop to add each item to display per row together.
example string
1;2;3;1;2;3;1;2;3
Then set the rowsource to the string you make.
Possibly requery the list box too.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 6th, 2006, 06:30 AM
#3
Thread Starter
New Member
Re: Creating MultiColumns ListBox from VBA array
Not Working.. what did I do wrong?
VB Code:
MyStr = ""
For i = 1 To XmlLastColumn
MyStr = MyStr & XMLcolumns(i) & ";"
Next
MyStr = Left(MyStr, Len(MyStr) - 1)
frmXmlColumns.lstXmlCol.RowSource = MyStr
-
Jun 6th, 2006, 06:35 AM
#4
Re: Creating MultiColumns ListBox from VBA array
Code:
Dim MyArray(3, 3)
For i = 1 To 3
For k = 1 To 3
MyArray(i, k) = i & k
strToDisp = strToDisp & iif(len(strToDisp)>0,";","") & i & k
Next
Next
frmXmlColumns.lstXmlCol.RowSource = MyStr
Have you set the list box to values and set the column count to 3 (probably need to set the column widths to "1;1;1" as well) ?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 6th, 2006, 06:37 AM
#5
Thread Starter
New Member
Re: Creating MultiColumns ListBox from VBA array
OK... got the prob.. how do I set the listBox to values?
-
Jun 6th, 2006, 06:45 AM
#6
Re: Creating MultiColumns ListBox from VBA array
in MS Access
Design view
Select the list box
Right click > Properties (if the window isn't open)
Change to Data tab
The rowsource and type are there. Change the type to values.
Change tab back to format (the first tab)
Change column count and column widths here
Save form
Close and see if the code runs
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 6th, 2006, 06:48 AM
#7
Thread Starter
New Member
Re: Creating MultiColumns ListBox from VBA array
I'm sorry, I should have say that befrore - I'm using Excel, not Access. No "Type" field overthere...
-
Jun 6th, 2006, 07:17 AM
#8
Re: Creating MultiColumns ListBox from VBA array
I had a feeling you were going to say that.
Ok.. I tried via a userform > list box On the properties window, change to categorised. scroll down to data - should be on there.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 6th, 2006, 07:43 AM
#9
Thread Starter
New Member
Re: Creating MultiColumns ListBox from VBA array
Sorry. No "Type" fuels ynder Data Category...
Excel do have:
1. BoundColumn (1)
2. ColumnCount (3)
3. ColumnHeads (False)
4. ColumnWisths
5. ControlSource
6. ListStyle (0 - fmListStylePlain)
7. RowSource
8. Text
9. TextColumn (-1)
10. TopIndex (-1)
-
Jun 6th, 2006, 08:16 AM
#10
Re: Creating MultiColumns ListBox from VBA array
Try Rowsource for the string data. Forget the type. I was thinking in Access sorry
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 6th, 2006, 08:27 AM
#11
Thread Starter
New Member
Re: Creating MultiColumns ListBox from VBA array
It didn't work... It works only for "real" source as rows and columns in the Excel sheet..
I will manage without it...
Thanks!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|