Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default help extracting a value in VBA

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default help extracting a value in VBA

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("Erro r Codes") _
..Range("T10:T45"))
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Peter Bailey" 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default help extracting a value in VBA

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.
:)


"Ron de Bruin" wrote in message
...
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("Erro r Codes") _
.Range("T10:T45"))
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Peter Bailey" 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
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
Extracting First Name Ruan New Users to Excel 12 February 15th 06 05:41 PM
extracting last name maryj Excel Worksheet Functions 4 June 29th 05 08:55 PM
extracting dd from dd/mm/yy KC Excel Worksheet Functions 4 November 27th 04 12:57 PM
extracting IF Dave Peterson[_3_] Excel Programming 0 September 26th 03 02:38 AM
extracting IF Myrna Larson[_3_] Excel Programming 0 September 26th 03 02:17 AM


All times are GMT +1. The time now is 12:12 PM.

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"