View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave[_85_] Dave[_85_] is offline
external usenet poster
 
Posts: 5
Default Worksheet_BeforeDoubleClick subtract sum of cells below top cell

On Friday, January 1, 2021 at 1:29:22 AM UTC+10:30, Peter T wrote:
Dave,

I think you will need to explain much more clearly what you want to do. I
sort of got the gist but not enough to even think making a suggestion.

Peter T


Hello Peter,

I realised this probably did not make sense so I thought I had deleted the post, so I was surprised to get a reply.

What I had been trying to achieve was a Worksheet_BeforeDoubleClick macro where you could double click in a blank below a range of contiguous values and it would insert a formula that would take the range of cells above the active cell formula and below the top value (below a blank cell) and subtract them from the top value, something like:
(top cell) 5,810 minus (next cell down) 1,220 minus (next cell down) 690 minus (next cell down) 1,000 = 2,900
= 5,180 - 1,220 - (1,380 / 2) - (500 + 500) = 2,900
Which is effectively subtracting every value from the first/top value, but these contiguous cells/rows vary in size.
The other way of looking at it is effectively subtracting the SUM of all the values below the first/top cell from the first/top cell, but not using specific cell references written into the macro.

As the column may contain multiple contiguous groups I wanted to restrict the Worksheet_BeforeDoubleclick macro to individual contiguous groups and not the whole column.
I am hoping the macro will not be column or row specific, but be able to be used anywhere on the worksheet and not affected by any other contiguous groups in a column.

I hope this explanation make more sense ?

Regards, Dave