+ Reply to Thread
Results 1 to 10 of 10

Excel VBA: Put dictionary key and item in columns without transposing

  1. #1
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Excel VBA: Put dictionary key and item in columns without transposing

    I have a macro that creates a dictionary with over 30k entries. My problem now is that I would like to have these entries show in columns in excel. Excel has a maximum number of column entries that doesn't allow me to put my keys in and then transpose them. Is there a way around this?
    Last edited by manofcheese; 07-20-2015 at 09:40 AM.

  2. #2
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    319

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    Can you tell us why you want to store them this way? If it's just a question of presentation, then you are probably going to be stuck with the column limit. If there are other reasons (not to do with presentation) it might be that you simnply want to report the subset in which you are interested in the horizontal format.

    Stating the underlying reason for wanting something is frequently a way to clarify exactly what it is, and why, that you want to do,

    Thanks,

    Tony

  3. #3
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    Sorry. I think I was unclear. I would like all the keys to be in one column and all the values in another. The problem that I have is as soon as I try to put my dictionary into a column it has to be transposed to be in a vertical layout. This means that it has to go from having all data in one row to all data in one column. Because of the amount of data I have, I cannot put it in the row to begin with before transposing it into a column.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    Just write it to a 2d vertical array before sticking it in sheet

  5. #5
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    Could you explain how I do this? Here is the code that I am using right now. It counts up the number of times each word occurs in a range and puts it into a dictionary. I am trying to get these to go into a column. I found this code here and modified it a little.
    Please Login or Register  to view this content.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,615

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    Since the output goes into columns (like you want them to be) I don't really get your question.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    @bakerman because transpose is slow and has limits on the number of elements

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,615

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    Your solution worked great bakerman2. Thanks

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,615

    Re: Excel VBA: Put dictionary key and item in columns without transposing

    You're welcome.

    Kyle123 can share the credit because it was his suggestion in Post#4 I put to use.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Can a dictionary key hold more than one item?
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-17-2015, 07:00 AM
  2. [SOLVED] Can a dictionary key hold more than one item?
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2015, 04:37 AM
  3. [SOLVED] If dictionary key exists add new item to existing item array
    By strud in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-25-2014, 01:54 PM
  4. [SOLVED] accesing class members of an object returned by dictionary item
    By vientito in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2014, 05:08 PM
  5. [SOLVED] Transposing dictionary keys and items into one column
    By strud in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-29-2013, 09:42 AM
  6. Remove All Instances Of Key Item Pairs From Dictionary
    By goss in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-31-2013, 12:37 AM
  7. 2 Dimentional Array as Dictionary Item
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-05-2011, 11:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1