Solved

Extracting data from scripting dictionary

Posted on 2014-09-19
2
94 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

776 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