Solved

Extracting data from scripting dictionary

Posted on 2014-09-19
2
95 Views
Last Modified: 2014-09-19
Hi

I have recently come across the dictionary object in Excel VBA.    The code below (same in the workbook) does a fine job of going through a list of names ignoring all duplicates.
I know that the dictionary contains the information, but I don't know how to extract the contents of the dictionary.  I  would like the transfer the contents of the dictionary to a string array.  

Thank you.



The excel workbook included has one "button" with the following code.

Private Sub CommandButton2_Click()
    Dim NameList() As Variant
    Dim dict As Object, c As Variant, i As Long, lr As Long
    Set dict = CreateObject("Scripting.Dictionary")
    lr = Cells(Rows.Count, 1).End(xlUp).Row

    c = Range("a1:a45" & lr)
    
    For i = 1 To UBound(c, 1)
    dict(c(i, 1)) = 1
    Next i
       
End Sub

Open in new window

Accumulated-Time-2.xlsm
0
Comment
Question by:peispud
2 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 40333384
Try this.
arrDict = NameList.Keys

Open in new window

0
 

Author Comment

by:peispud
ID: 40333399
Too easy!

Brains beats brawn.

Thank you very much!!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question