Solved

Extracting data from scripting dictionary

Posted on 2014-09-19
2
89 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
Comment Utility
Try this.
arrDict = NameList.Keys

Open in new window

0
 

Author Comment

by:peispud
Comment Utility
Too easy!

Brains beats brawn.

Thank you very much!!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
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 …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now