View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_2_] Alan Beban[_2_] is offline
external usenet poster
 
Posts: 783
Default How to read a collection name index value?

Dana DeLouis wrote:
If IsError(V) = True Then



Here's another way to test...

Sub Demo()
Dim d As Scripting.Dictionary
Set d = New Scripting.Dictionary
d.Add "a", "aaa" 'Add key - Items
d.Add "b", "bbb"
d.Add "c", "ccc"

If d.Exists("c") Then
MsgBox "Index is: " & WorksheetFunction.Match("c", d.Keys, 0)
End If
End Sub

Well, aside from the fact that Dana DeLouis's approach gives 3 as the
index for "c" and Chip Pearson's approach gives 2 (which is correct),
isn't the Op's assigned exercise to find the Index of a specified Item
(analogous to an Item of a Collection) rather than of a specified Key?

Alan Beban