nbala75 Posted December 30, 2010 Share Posted December 30, 2010 (edited) Iam pretty poor in loopsfor some of u this may be very easy...after some couple of hrs i can only faillet me know how u guys write a loop for this...-- 50 rows in this array-- this is just an eg..array's size may vary-- period is 25 (can be changed to any number)-- Bottom up-- first row in new field in just an average of last field [49] to [25], which is equal to Period of 25-- rest of the row's formula is given in attached snapshotsHope some one helps Edited December 30, 2010 by nbala75 Link to comment Share on other sites More sharing options...
kylomas Posted December 30, 2010 Share Posted December 30, 2010 nbala75, Glad to help...what is the question? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
nbala75 Posted December 30, 2010 Author Share Posted December 30, 2010 nbala75, Glad to help...what is the question?kylomasOhh..thank uI need to populate the right hand side column using the above formulasThe first field of the new array (from bottom) shud be the AVG of <period=25> rows from bottom of TR array (posted as first snapshot)The rest of rows (from bottom) shud be populated using the given formula in snapshots of excelplz help me out Link to comment Share on other sites More sharing options...
ZacUSNYR Posted December 30, 2010 Share Posted December 30, 2010 Not sure what code you need but the loop is easy enough to do Global $aExample[50] $aExample[0] = "1" $aExample[24] = "25" $aExample[49] = "50" $n = UBound($aExample) - 1 ; Use UBound to get the size of the Array when it has no index. ConsoleWrite(@CRLF & "Array Size: " & $n & @CRLF) ; Go from 24-49 ConsoleWrite("Count up from 24 to end of array" & @CRLF) For $i = 24 To UBound($aExample) - 1 ConsoleWrite($aExample[$i] & ".") Next ; Go from 49-24 ConsoleWrite(@CRLF & @CRLF & "Count down from end of array to 24" & @CRLF) For $i = UBound($aExample) - 1 To 24 Step -1 ; Notice the Step -1 ConsoleWrite($aExample[$i] & ".") Next Link to comment Share on other sites More sharing options...
nbala75 Posted December 30, 2010 Author Share Posted December 30, 2010 Not sure what code you need but the loop is easy enough to do Global $aExample[50] $aExample[0] = "1" $aExample[24] = "25" $aExample[49] = "50" $n = UBound($aExample) - 1 ; Use UBound to get the size of the Array when it has no index. ConsoleWrite(@CRLF & "Array Size: " & $n & @CRLF) ; Go from 24-49 ConsoleWrite("Count up from 24 to end of array" & @CRLF) For $i = 24 To UBound($aExample) - 1 ConsoleWrite($aExample[$i] & ".") Next ; Go from 49-24 ConsoleWrite(@CRLF & @CRLF & "Count down from end of array to 24" & @CRLF) For $i = UBound($aExample) - 1 To 24 Step -1 ; Notice the Step -1 ConsoleWrite($aExample[$i] & ".") Next thank u...the size of the first array(no of rows) is dynamic and the period(p=25) is also flexible....can this work with these parameters as well?? let me check this as well...thanx again Link to comment Share on other sites More sharing options...
ZacUSNYR Posted December 30, 2010 Share Posted December 30, 2010 The size of the array being dynamic is fine (Check out the function UBound that was used in the example in the help file). The starting/ending point needs to be specified one way or another. You can assign it to a variable and set that variable at some point in the loop. The 'To 24 Step -1' section is where it'll stop (the 24) Link to comment Share on other sites More sharing options...
nbala75 Posted December 30, 2010 Author Share Posted December 30, 2010 (edited) The size of the array being dynamic is fine (Check out the function UBound that was used in the example in the help file). The starting/ending point needs to be specified one way or another. You can assign it to a variable and set that variable at some point in the loop. The 'To 24 Step -1' section is where it'll stop (the 24)yeah...that is what i was just expecting someone to write it for me...bcos, i dont have formal edu in programming and i have not come across this type before, so iam finding it difficult to get this across to my mind...some of u guys who have done way above of these simple loops, will be able to do it in ur left hand...and that wud be a starting point for guys like me to learn the tricks in doing this in a simple and better way...iam sure i cannot write 1 to 24 as numbers in the loop since i do not know whether it is 24 or 20 for that matter. This has to be derived, as u had said abt assigning and setting at some point in the loop. Edited December 30, 2010 by nbala75 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now