Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi there, please can anyone help. Have some VBA calculating a sum from
values in column E. Got the code from this google group, and have just about worked out how it works. However, I don't know how to adapt it so that it does a sum even if there is only one value to sum. I pressume it is something to do with how the range is calculated. This is what I've got. lr = Cells(Rows.Count, "c").End(xlUp).Row e1 = Cells(1, "c").End(xlDown).Row Do Until e1 = lr e2 = Cells(e1, "c").End(xlDown).Row Set myrange = Range(Cells(e1, "e"), Cells(e2, "e")) Cells(e1 - 1, "c") = Application.sum(myrange) e1 = Cells(e2, "c").End(xlDown).Row Loop this is what the data looks like after the macro has been run. A B C D E 0 b333333 141.88 20/06/2006 1 b333333 125001 1 28.49 1 b333333 125003 1 37.89 1 b333333 125005 1 75.50 0 b222222 108.12 20/06/2006 1 b222222 125007 1 88.34 0 B444444 20/06/2006 1 B444444 125009 1 19.78 1 B444444 039001 1 2.77 I think it should calculate from the bottom value until there is a blankcell and then offset the total into column C in the row above, but it falls over if there is a single value to calculate. It has also missed the bottom value off this calculation, but all works perfectly if there is more than one value to sum. I would be gratefull for any suggestions. Thanks in advance, BevJ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to update a column in a work based on another work sheet | New Users to Excel | |||
how can i automatically generate work order numbers from work orde | Excel Discussion (Misc queries) | |||
flash object dont work in my excel work sheet | Excel Discussion (Misc queries) | |||
Counting dates in multiple work sheets and work books | Excel Discussion (Misc queries) | |||
Is there away to keep "auto save" from jumping to the first work sheet in the work book? | New Users to Excel |