sum code based on variable range

The Idea Dude

Well-known Member
Joined
Aug 15, 2002
Messages
591
Office Version
  1. 2016
Platform
  1. Windows
Hey everyone!

Lets say I am arriving at some cells and I dont know what they are going to be before I arrive at them, how do I do a sum under the following circumstances using the following example.

A10 is the active cell and where the formula has to go
A9 contains a number
A8 contains a number
A7 Contains a number
A6 is empty (It will be the active cell as my loop progresses and I will be back at the same situation as with A10 at the moment but I may not necessarily have 3 cells above, i might only have 1 with a number in it)

So with the above, A10 would need to sum A9, A8, A7 and thats it because A6 is empty. So in essence the code needs to sum up from the active cell until it reaches an empty cell.

Thanks :)
 
Yes you are correct, it does produce that error, I did try it on some single cells above active cell but the cells 3 above active cell where 0 so i didnt spot the error.
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,221,604
Messages
6,160,748
Members
451,670
Latest member
Peaches000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top