Solved

Extracting data from scripting dictionary

Posted on 2014-09-19
2
99 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

622 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