probably an easy question for you but I'm stuck

J

jpballegeer

And I can't find a good start Site

The problem is the following. I have an range in excell. For every cell
I have to calculate the sum of the previous 30 cells in fe row A.(so
far a piece of cake) Next to those cells there can be a letter fe V. If
there is such a letter you have to add it with the amount of V's that
I've found. that result has to be placed in row C.

So if in the range of 30cells there are 5 cells with v, he has to make
the sum of 35 cells. And if in the consecutive 5 cells is a V, they
have to be added aswell.

I've made the formula with my own syntax but I don't know how to start
making it work in vba. Here it is:

Count1 V in (currentcell(row-1)(column-1)):
(currentcell(row-1)(column-30))
result result1

Count2 V in (currentcell(row-1)(column-1) :
(currentcell(row-1)(column-30-result1))
result result2

if result1=result2
goto count3
else copy result2 to result1
goto count2

Count3
Sum(currentcell(row-1)(column-1)):(currentcell(row-1)(column-30-result2))
put result in currentcell

Anybody a hint for me?
 
T

Tom Ogilvy

Put this in the start cell in column C (where you want the sum for A1:A30 +)


=SUM(OFFSET(A1,0,0,30,1))+SUM(OFFSET(A1,30,0,COUNTIF(B1:B30,"V"),1))*(COUNTIF(OFFSET(B1,30,0,COUNTIF(B1:B30,"V"),1),"V")>0)

then drag fill down the column.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top