Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default iterating through a Dictionary object


Hi all,

Is there a way to iterating through the entire dictionary object. I want to
do a Debug.Print to see all the keys and the items values in the Immediate
Window.

Thanks in advance,

Ben


--

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default iterating through a Dictionary object

Try code like


Dim V As Variant
For Each V In Dict.Items
Debug.Print V
Next V

' or

Dim N As Long
For N = 0 To Dict.Count - 1
Debug.Print "Value: " & Dict.Items(N), "Key: " & Dict.Keys(N)
Next N


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Ben" wrote in message
...

Hi all,

Is there a way to iterating through the entire dictionary object. I want
to
do a Debug.Print to see all the keys and the items values in the Immediate
Window.

Thanks in advance,

Ben


--


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default iterating through a Dictionary object

You can use a for each something like this...

Sub test()
Dim dic As Object
Dim dicItem As Variant

Set dic = CreateObject("Scripting.Dictionary")

dic.Add "this", "This"
dic.Add "That", "That"

For Each dicItem In dic
Debug.Print dicItem
Next dicItem

End Sub
--
HTH...

Jim Thomlinson


"Ben" wrote:


Hi all,

Is there a way to iterating through the entire dictionary object. I want to
do a Debug.Print to see all the keys and the items values in the Immediate
Window.

Thanks in advance,

Ben


--

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default iterating through a Dictionary object

Thanks Jim.

Ben

--



"Jim Thomlinson" wrote:

You can use a for each something like this...

Sub test()
Dim dic As Object
Dim dicItem As Variant

Set dic = CreateObject("Scripting.Dictionary")

dic.Add "this", "This"
dic.Add "That", "That"

For Each dicItem In dic
Debug.Print dicItem
Next dicItem

End Sub
--
HTH...

Jim Thomlinson


"Ben" wrote:


Hi all,

Is there a way to iterating through the entire dictionary object. I want to
do a Debug.Print to see all the keys and the items values in the Immediate
Window.

Thanks in advance,

Ben


--

  #5   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default iterating through a Dictionary object


Thanks Chip.

Ben


--



"Chip Pearson" wrote:

Try code like


Dim V As Variant
For Each V In Dict.Items
Debug.Print V
Next V

' or

Dim N As Long
For N = 0 To Dict.Count - 1
Debug.Print "Value: " & Dict.Items(N), "Key: " & Dict.Keys(N)
Next N


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Ben" wrote in message
...

Hi all,

Is there a way to iterating through the entire dictionary object. I want
to
do a Debug.Print to see all the keys and the items values in the Immediate
Window.

Thanks in advance,

Ben


--


Reply
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
ByRef argument type mismatch when passing dictionary object signon77 Excel Programming 7 January 8th 08 10:03 PM
Using the Dictionary object vqthomf Excel Programming 5 April 10th 07 05:42 PM
Dictionary object: Error assigning user defined data type to item Paul Urbanus Excel Programming 2 December 1st 05 04:21 AM
Dictionary Object in Windows XP Alan Beban[_2_] Excel Programming 5 March 13th 05 08:04 PM
iterating through all properties of an object Barney Fife Excel Programming 4 August 22nd 03 03:18 AM


All times are GMT +1. The time now is 12:47 AM.

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

About Us

"It's about Microsoft Excel"