# Solved: Macro to sum 3 columns using a loop

Discussion in 'Business Applications' started by TrauTs-Art, Jan 22, 2013.

Not open for further replies.

Joined:
Jan 19, 2013
Messages:
3
Hi All, fantastic site.

I need to run a macro in excel to sum the following.

check row 3 col 3 or row 3 col 4 for a value > 0 then subtract this value from row 3 col 5 return answer to Row 3 col 6 if col 5 cell is empty then go to previous cell that has a value >0 return this value to Col 6 on the same row as col 3 or 4 (the one with a value >0)
There should be an answer in every row col 6 this could run upto 100 rows+

Hopefully i've explained myself engough for you to understand. Ta

2. ### Garf13LD

Joined:
Apr 17, 2012
Messages:
455
@F3
=if(E3,E3-max(C33),max(C33))

Joined:
Jan 19, 2013
Messages:
3
I have place the formula in column F row 2 dragged it down and all I get is "false" nice trt but that did not seam to work.

My problem starts at row 5.

I have data in colC row 4 & 5, col D row 3 , 6, 7 colE row 2,3,6 allthe remaining in between are zero. Starting with col F row 3 the formula I've entered is = E2-D2 then moving down to the next cell same column row 4 the formula is =E3-C4, then moving down to the next cell I have E3-C5 as you can see I have to go back to E3 becouse E4 = 0 also does E5 so on and so on. What I 'm looking to achieve is when column E has a zero then the previous cell that is >0 needs to be used however the sequence needs to remain eg E6 E7 E8 as there will always be a value >0 in column 5.

4. ### Garf13LD

Joined:
Apr 17, 2012
Messages:
455
Pls attach a sample file

Joined:
Jan 19, 2013
Messages:
3
Please see attached file, hopefully this will help resolve.

File size:
10.6 KB
Views:
31

As Seen On