View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default How to read a collection name index value?

I haven't found one that works for everything. Sheets("sheet1") works but it
doesnn't work for shapes. I have jsut given up and use the good old for loop

found = false
for each Giz in Gizmos
if Gizmos.name = "SomeName" then
found = true
exit for
end if
next Giz

if found = true
etc
etc, etc
etc, etc, etc
end if

"G Lykos" wrote:

Greetings!

You can use a collection index value, for example Gizmos(13).Name, to get
the name of item 13. Am wondering if there is an equivalent direct
mechanism to use a collection item name to get its index value, along the
lines of Gizmos("SomeName").Index. If symmetrical functions (properties, I
guess, in VBA speak) existed, Gizmos(Gizmos("SomeName").Index).Name would
return "SomeName" - an identity property of sorts.

I suppose a brute-force approach would be to create a function doing a For
name/string comparison loop over 1 to Gizmos.count. Am hoping for something
more direct.

Thanks,
George