I am trying to convert a 1D array to a 2D. Below is where I am up to so far. I just need help with the Redim Preserve line. Can any of you nice array experts help out please?
Please Login or Register to view this content.
I am trying to convert a 1D array to a 2D. Below is where I am up to so far. I just need help with the Redim Preserve line. Can any of you nice array experts help out please?
Please Login or Register to view this content.
*******************************************************
HELP WANTED! (Links to Forum threads)
Trying to create reusable code for Custom Events at Workbook (not Application) level
*******************************************************
Can't you just use the transpose function?
Last edited by mc84excel; 05-24-2013 at 03:33 AM. Reason: Bolded...In case anyone else stumbles on this thread and gets diverted off this thread question
Yeah have a look at my comment on that thread. Transposing gives you a 2 d array, wheres the issue?
ms84excel, could you attach a file with your troubled ListBox
Hello nilem,
- It would mean having to remove a large amount of confidential data. (I may have to go down that route if I cant convert a 1D array to a 2D array).
- No offence intended - but would you mind posting this comment in the other thread? I would like to keep this thread focused on converting a 1D array to 2D. Thanks.
What does:
Actually mean? In what way doesn't it work for you? Application.Transpose transposes an array:Sorry Kyle. It doesn't work for me.
Please Login or Register to view this content.
Sorry that is my fault for not clarifying.
- In my thread about 1D arrays to a ListBox, I have explained what happened when I tried your suggestion.
- No offense intended - but would you please keep any posts relating to the "1D array to a ListBox" issue on that thread - not this one (which is meant to be about converting a 1D array to a 2D array...)
Everyone,
Please please keep your posts on this thread relating to the topic (Converting a 1D array to a 2D array).
If you have any suggestions on how to populate a ListBox with a 1D array, please post them in the other thread.
Thank You!
Last edited by mc84excel; 05-24-2013 at 03:34 AM.
Eh? I'm not talking about listboxes, in this thread I'm talking bout conveting a 1d array to 2d
Just put a break point in and inspect it in the locals window. Transpose works due to how Excel understands rows and columns, rows are single dimensioned, columns have 2 dimensions.
I tried transposing the 1D array but it didn't make it 2D. (Locals window still showed Variant/Variant(1 to 3).
I solved the sub - the code below will make a 1D array into a 2D array (Locals window will show Variant/Variant(1 to 3, 1 to 2) after running the sub).
This adds the 1D array contents to the 1st column. If you need the 1D array contents to the 1st row instead then change the last line of the sub to transpose the varArrayOutput.
Please Login or Register to view this content.
Updated version. Note the module is set to Option Base 1
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks