Solved

Extracting data from scripting dictionary

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

751 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