Tuesday, 14 September 2010

Intialize your Array... (No Loops)

Many Many Codes so far use loops to process, loops to intialize and loops to output... No Harm except the wasted time of user and effort of pc..

In order to overcome this issue i have came across one of the great solutions which had always thought of to practise in VBA is to intialize an array using a single line decalaration and with out loops to a defualt value may be even a string...

The following solutions of mine following illustrates my point.

Sub Demo()
Dim M() As Variant
'This will intialize your array with "-"
M = [if(isnumber(ROW(A1:J10)),"-",99)]
'This will intialize your array with integer value 5
End Sub

Check this excitng code out and gain the advantege of being a smart programmer ....

No comments: