vba question on adding certain columns
I have something to do in visual basic and apparently I dont know how to do it:(. So I need a bit of a help. I have two sheets in excel: Sheet 1 and Sheet 2
In Sheet1 I have something like
2008 2009 2008
Name1 10 20 30 40 50 60 20 10 15 20 40 60
Name2 60 20 40 70 70 20 30 10 25 35 70 90
Name3 50 20 30 10 50 20 10 30 50 30 40 50
....
I dont know how many years I have. I can have 4,5, etc
In the Sheet2 I will have to have something like
2008 2009
Name1 25 40 70 100 50 60 20 10
Name2 85 55 110 160 70 20 30 10
Name3 100 50 70 60 50 20 10 30
....
Meaning, if I have the same year multiple times, I add the values (in the ex: I add first column from the first 2008 with the first column from the second 2008 and so on) and if I have just one year then I just have to copy it as it is in Sheet2.
I was thinking to define a name in excel on the same row where I have the years and using offset in vba (I know the exact position of the years) to see if I have more times the same years. I even did that (kind off) but I cant seem to make it for several years and for several columns.
I could really use some help so if you can... help!! :)
Thank you!
Csilla
|