Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Make sure all items in a Collection equal the same thing

Is there another way to test if all item value in a Collection or Array are
the same thing? For example, I want to make sure that all items in the
Collection or Array = "Complete". here is the code I use. I was wondering
if I am doing this a long about way.

For j = 1 To colSalesOrderStatus.Count - 1
If colSalesOrderStatus(j) < colSalesOrderStatus(j + 1) Then
'do something
Exit For
End If
Next j
--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Make sure all items in a Collection equal the same thing

Hi Ryan

First I would test against the desired value ie. < Complere,

the I would use this loop:

For Each colItem In colSalesOrderStatus
If colItem < "Complete" Then
'Do something
Exit For
End If
Next

Regards,
Per

On 24 Sep., 00:20, RyanH wrote:
Is there another way to test if all item value in a Collection or Array are
the same thing? *For example, I want to make sure that all items in the
Collection or Array = "Complete". *here is the code I use. *I was wondering
if I am doing this a long about way.

*For j = 1 To colSalesOrderStatus.Count - 1
* * *If colSalesOrderStatus(j) < colSalesOrderStatus(j + 1) Then
* * * * * 'do something
* * * * * Exit For
* * * End If
*Next j
--
Cheers,
Ryan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Make sure all items in a Collection equal the same thing


Hi Ryan

First I would compare against a constant value, earlier elements in my
collection as it requires that first item is equal to "Complete"

Second, my code would look like this:

For Each colItem In colSalesOrderStatus
If colItem < "Complete" Then
'Do something
Exit For
End If
Next

Regards,
Per

On 24 Sep., 00:20, RyanH wrote:
Is there another way to test if all item value in a Collection or Array are
the same thing? *For example, I want to make sure that all items in the
Collection or Array = "Complete". *here is the code I use. *I was wondering
if I am doing this a long about way.

*For j = 1 To colSalesOrderStatus.Count - 1
* * *If colSalesOrderStatus(j) < colSalesOrderStatus(j + 1) Then
* * * * * 'do something
* * * * * Exit For
* * * End If
*Next j
--
Cheers,
Ryan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Make sure all items in a Collection equal the same thing

Thanks for the reply, but I was wondering if there was a shortcut way of
testing if all objects in the collection are the same. I already have a
loop. Plus the loop you wrote won't work for me because the collection may
contain all strings such as "Complete", "Ready", or "Archive".

I was thinking something like this: I know this doesn't work, for
demonstration purposes

Collection.AllValues = "Complete"
--
Cheers,
Ryan


"Per Jessen" wrote:


Hi Ryan

First I would compare against a constant value, earlier elements in my
collection as it requires that first item is equal to "Complete"

Second, my code would look like this:

For Each colItem In colSalesOrderStatus
If colItem < "Complete" Then
'Do something
Exit For
End If
Next

Regards,
Per

On 24 Sep., 00:20, RyanH wrote:
Is there another way to test if all item value in a Collection or Array are
the same thing? For example, I want to make sure that all items in the
Collection or Array = "Complete". here is the code I use. I was wondering
if I am doing this a long about way.

For j = 1 To colSalesOrderStatus.Count - 1
If colSalesOrderStatus(j) < colSalesOrderStatus(j + 1) Then
'do something
Exit For
End If
Next j
--
Cheers,
Ryan



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
can I make cell "yes" equal 1, "no" equal 0 can I make cell yes equal 1, no equa Excel Discussion (Misc queries) 4 April 22nd 23 06:09 AM
multiple formual'a that equal the same thing machinist 101[_2_] Excel Worksheet Functions 2 March 5th 09 03:28 AM
Adding Unique Items to a Collection WJ Excel Discussion (Misc queries) 2 June 12th 07 03:46 PM
Class Collection Add Items keep repeating Kevin Vaughn Excel Programming 3 April 18th 06 10:50 PM
Clearing all items in a collection Todd Huttenstine Excel Programming 5 August 13th 04 09:45 PM


All times are GMT +1. The time now is 05:45 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"