Saturday 15 January 2011

For-Next Loop and Arrays - VBA -


I'm making the same mistake, and I do not know what it is. Every time I make a loop working with aero (usually, reading an array and writing values ​​in a second array), it only takes a lot from the first array and it is in every slot in the other Writes array.

Here I am doing the easiest / least one. It should read the values ​​of A1: A10 and write them in B1: K1. I = 1 to 10 A (i) = range ("A") as a dim B (1, 10) in the form of anomaloid (1 to 10) sub-problem (1 to 10)

  For the CSTR (i), the single dim Ii as the integer Value for I = 1 to 10b (1, i) = a (i) Next I category ("b1: k1") = b (1, 10) end sub    

  range ("b1: k1") = b (1, 10)   

This only copies an array element.

You can do the following:

  Range ("B1: K1"). Value = app Worksheet Function _. To store the original values ​​in an array (using my viewpoint) to the transbase (range ("A1: A10"))   

Unfortunately:

  Sub problem 1 () A type of variant A = category ("A1: A10") range ("B1: K1" ) = Application. Worksheet Function. If you still want to use both arrays:  sub problem 1 () same version dim B (transit (A) and all   

1 to 10) Integer A = range like I i as a single D ("A1: A10") i = 1 to 10b (i) = one (i, 1) Next I range ("B1: 1 ") = b & all / pre>

No comments:

Post a Comment