Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Q: Better syntax to cycle through elements of an array?

A method that does not require any iteration...

MsgBox Evaluate("sum(abs(trunc(C1:I1)-C1:I1))") = 0

Adjust for your own needs.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article <01c38dd6$387ade40$476a1bac@PC12001,
says...

I'm writing some code to pull ranges from different data worksheets (always
one row, column C to AM) into an array, validate the data (make sure only
integers are present), do some calculations on the data (simple division),
put the results in a new array (two dimensional), then drop the contents of
that new array into a new target range.

When I pull the data in, I need to validate it to make sure that everything
that is pulled in is an integer (or blank). I'm wondering what syntax I
could use to cycle through an array in VBA, similar to:

For each (object) in (collection). What is the "name" of the object of one
"bucket" in an array?

I'm also having trouble with the syntax to pull the range into the array,
if anyone wants to give me a syntax hint there :)
is it because I'm declaring the size of the array, rather than an open
variant? If I did use a variant, can I treat it like an array without
cycling through anyway to dump it into an array? (I've tried dimming the
array as 2 dimensional as well, e.g. (1 to 1, 1 to 38) and that didn't seem
to work either)

Thanks,
Keith
XL97


Snippet:

Dim TArray(1 To 38) ' to hold my values from column C to AM

For RVal = 1 To 5 ' row number to pull the range from
UseRange = "C" & Trim(Str(RVal)) & ":AM" & Trim(Str(RVal))
' next line has had many tweaks, but still not working
TArray = ActiveSheet.Range(UseRange).Value
' I want to insert better syntax here, vs:
For i = 1 to 38
if isnumeric(TArray(i).value) then
if mod(TArray(i).value,1)=0 then
'do stuff
end if
end if
Next
Next


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
Conversion of Array Elements to PerCent Confused_in_Houston Excel Discussion (Misc queries) 2 October 2nd 08 03:58 AM
Use formulas for array elements hmm Excel Discussion (Misc queries) 3 December 3rd 07 01:15 PM
Reference Elements w/in an Array M Moore Excel Discussion (Misc queries) 2 October 16th 06 03:33 PM
Non-unique elements in an array Andrew Excel Discussion (Misc queries) 1 August 22nd 05 11:58 AM
Q: Better syntax to cycle through elements of an array? Tom Ogilvy Excel Programming 3 October 9th 03 09:38 PM


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