LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Please Help: Transferring from Dictionary to Array

Column A in my worksheet contains repetitive values. I have a macro that
creates a dictionary object and loads it with unique values from the column.
When I try to load the dictionary items into an array, its not working out.
The array does not seem to contain any values (as the msgbox function is not
returning anything). The macro is pasted below.

I cant figure out what I'm doing wrong. Any help would be greatly appreciated.

Thank You!

Magnivy

Sub Macro()

Dim rng As Range
Dim x As Dictionary
Dim arr() As Object
Dim Cell As Object
Dim i As Integer
Dim t As Integer


Set rng = ActiveSheet.Range("A1:A500")

Set x = CreateObject("scripting.dictionary")

On Error Resume Next
For Each Cell In rng.Cells
x.Add Item:=Cell.Value, Key:=CStr(Cell.Value)
Next Cell

ReDim arr(1 To x.Count)

i = 0

For Each Item In x.Items
i = 1 + i
arr(i) = Item
Next Item

For t = 1 To UBound(arr, 1)
MsgBox arr(t)
Next t

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
transferring array to range JackRnl Excel Programming 4 August 8th 06 01:13 AM
Problem transferring array data onto worksheet using Resize Ken Johnson Excel Programming 13 December 20th 05 02:05 AM
Transferring part of a multi-dimensional array to a range in VBA Bob J.[_3_] Excel Programming 1 July 27th 05 03:38 PM
dictionary Libby Excel Programming 0 November 15th 04 12:53 PM


All times are GMT +1. The time now is 02:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"