Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() If I'm looping thru an array of objects with 'For Each', how do I test for the last good one? If I test for "" or 0, it says "not supported" If I test for Nothing, it says "invalid use of object" Thanks, Peter. (Excel VBA under XP) *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Whatever you're iterating through probably has a "count" property, so
you could try using a counter and checking to see if you're on the last item. Or just keep a reference to the last object and use it once you're out of the loop. Tim. "peter" wrote in message ... If I'm looping thru an array of objects with 'For Each', how do I test for the last good one? If I test for "" or 0, it says "not supported" If I test for Nothing, it says "invalid use of object" Thanks, Peter. (Excel VBA under XP) *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It doesn't have a Count, probably because it's a dynamic construct.
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Then you could iterate the objects into a variant array and loop
through that instead (checking the ubound) Tim "peter" wrote in message ... It doesn't have a Count, probably because it's a dynamic construct. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter,
If it is an array, you'll LBound & UBound. No ? NickHK "peter" wrote in message ... It doesn't have a Count, probably because it's a dynamic construct. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think the problem is doing the test of the Variant, whereever it comes
from. Why do I have to use a Variant anyway? Shouldn't it understand if I use the class of the contained objects? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter,
Try it as the object and see what compile error you get. NickHK "peter" wrote in message ... I think the problem is doing the test of the Variant, whereever it comes from. Why do I have to use a Variant anyway? Shouldn't it understand if I use the class of the contained objects? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
peter,
In a loop, you may use TypeName(element)?? A sample in use. http://puremis.net/excel/code/076.shtml Why do I have to use a Variant anyway? Please have a look at the For Each...Next Statement in the VBA help. [quote] For arrays, element can only be a Variant variable. [unquote] -- Regards, Colo http://www.puremis.net/excel/ "peter" wrote in message ... I think the problem is doing the test of the Variant, whereever it comes from. Why do I have to use a Variant anyway? Shouldn't it understand if I use the class of the contained objects? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Alternative approach. Create a collection class for the objects and build a
Count property. -- HTH RP (remove nothere from the email address if mailing direct) "peter" wrote in message ... If I'm looping thru an array of objects with 'For Each', how do I test for the last good one? If I test for "" or 0, it says "not supported" If I test for Nothing, it says "invalid use of object" Thanks, Peter. (Excel VBA under XP) *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
logical test, array, text and numbers | Excel Worksheet Functions | |||
Test for Single Character That is in an Array | Excel Worksheet Functions | |||
Trying To Store Shapes/Objects to an array ?? | Excel Programming | |||
Trying To Store Shapes/Objects to an array ?? | Excel Programming | |||
How can you make an array of objects? | Excel Programming |