help extracting a value in VBA

  • Thread starter Thread starter Peter Bailey
  • Start date Start date
P

Peter Bailey

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
 
Hi Peter

I don't know if I understand you correct ?

Why do you use a loop
You can use the sum function in VBA like this

Sub test()
MsgBox Application.WorksheetFunction.Sum(Worksheets("Error Codes") _
..Range("T10:T45"))
End Sub
 
Excellent, I find it harder in access as the envoronment does not return the
methods when I for example go range. (dot) like it does in access vba
environment.

thank you that is just what I needed.
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top