mardi 22 mars 2016

Looping a function over columns with different number of rows in VBA

I am dealing with a large dataset where every third column contains values for which I need to perform a function that takes value of 1 if it is positive than 0 and value of -1 if it is negative. Writing the function itself is no problem, but the dimensions of the data matrix are large and the columns are not of equal length. Thus I would need to be able to write a code that loops over the columns, performing the task, and saves the results in another matrix with equal number of colummns and rows of the same length. To be more concrete, an example of the dataset I am dealing with and what I want to achieve:

x1;x2;x3;x4
1;-1;2;4
-5;1;2;-1
1; ;2;1
3; ; ;-4
5; ; ; 
6; ; ;

And transfer this into:

y1;y2;y3;y4
1;-1;1;1
-1;1;1;-1
1; ;1;1
1; ; ;-1
1; ; ;
1; ; ;

x's and y's need to be on the same row.

Thank you in advance!



Looping a function over columns with different number of rows in VBA

Aucun commentaire:

Enregistrer un commentaire