Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with looping range and extracting value
I want to sum the values in a range and have the following code: Dim Total As Integer For Each c In Worksheets("Error Codes").Range("T10:T45").Cells Total = Total + c.Value Next ErrorCount = Total I added a watch to c and the looping works or at least appears to ye it wont extract a value despite the column t10 onwards having values. Regards in advance for assistance. Pete -- Pb2 ----------------------------------------------------------------------- Pb21's Profile: http://www.excelforum.com/member.php...fo&userid=1539 View this thread: http://www.excelforum.com/showthread.php?threadid=27011 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with looping range and extracting value
Pb21 wrote:
I want to sum the values in a range and have the following code: Dim Total As Integer For Each c In Worksheets("Error Codes").Range("T10:T45").Cells Total = Total + c.Value Next ErrorCount = Total I added a watch to c and the looping works or at least appears to yet it wont extract a value despite the column t10 onwards having values. Regards in advance for assistance. Peter "extract a value"??? Alan Beban |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with looping range and extracting value
Maybe you can just...
total = application.sum(Worksheets("Error Codes").Range("T10:T45")) Pb21 wrote: I want to sum the values in a range and have the following code: Dim Total As Integer For Each c In Worksheets("Error Codes").Range("T10:T45").Cells Total = Total + c.Value Next ErrorCount = Total I added a watch to c and the looping works or at least appears to yet it wont extract a value despite the column t10 onwards having values. Regards in advance for assistance. Peter -- Pb21 ------------------------------------------------------------------------ Pb21's Profile: http://www.excelforum.com/member.php...o&userid=15398 View this thread: http://www.excelforum.com/showthread...hreadid=270110 -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with looping range and extracting value
Your code works fine here, but it's an inefficient way of summing a
range. Try something like this, errorcount = Application.WorksheetFunction.Sum(Worksheets("Erro r Codes").Range("T10:T45")) Regards, Vic Eldridge Pb21 wrote in message ... I want to sum the values in a range and have the following code: Dim Total As Integer For Each c In Worksheets("Error Codes").Range("T10:T45").Cells Total = Total + c.Value Next ErrorCount = Total I added a watch to c and the looping works or at least appears to yet it wont extract a value despite the column t10 onwards having values. Regards in advance for assistance. Peter |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping thru a range of cells | New Users to Excel | |||
looping across columns in range? | Excel Discussion (Misc queries) | |||
Looping through a range of cells | Excel Programming | |||
Need help with looping through a dynamic range | Excel Programming | |||
looping through a range | Excel Programming |