Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Sum in vba only works for multiple values not for single values??

Hello there, have been provided with a lovely bit of code that adds
cells in column E and places total in column C in the row above the
values it is totalling.

The code works beautifully for adding 2 or more values together, but
falls over when there is only one value to sum.

Application.ScreenUpdating = False
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

Application.ScreenUpdating = True


Any one give me a clue as to what needs to happen for it to include sum
function for just one value?

0 B11111 60 20/06/2006
1 B11111 007005 20 20.00
1 B11111 007003 40 40.00
0 B22222 34.71 20/06/2006
1 B22222 003011 1 15.05
1 B22222 005001 1 19.66
0 B33333 38.06 20/06/2006
1 B33333 005003 1 24.48
0 B44444 20/06/2006
1 B44444 005005 1 13.58
0 B55555 20/06/2006
1 B55555 007001 1 33.57

This is the result I get, first 2 calculations fine, last 3 don't
work??????

Many thanks, Bev J

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VLookup multiple values - sum returned values into single cell se7098 Excel Worksheet Functions 12 April 2nd 23 07:32 PM
Counting multiple values within single cells Terry Bennett Excel Worksheet Functions 5 October 24th 06 06:10 PM
Looking up multiple values for a single name Aaron Dyck Excel Worksheet Functions 4 July 21st 06 07:34 PM
create a list of single values from multiple values Jordan Excel Worksheet Functions 3 November 3rd 05 11:25 PM
Search multiple values to return single values JANA Excel Worksheet Functions 8 October 27th 05 04:26 PM


All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"