LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sum Column in Array

Try looping through the values in column 3 of your array and test to see if the
values are really numeric.

If you have text (like '3 or ="3") in a cell (say A1), then a formula like
=sum(A1:a9) will ignore the value in the cell--even if it looks like a number.

For rCtr = LBound(myArr, 1) To UBound(myArr, 1)
msgbox myarr(rctr,3) & vblf & application.isnumber(myArr(rCtr, 3))
Next rCtr

Application.isnumber is the =isnumber() worksheet formula. It won't be fooled
by the strings that look like numbers. (VBA's isnumeric() is fooled by those
strings that look like numbers.)

Troubled User wrote:

Dave,

This is what I was trying, but it is returning 0, when I know there are
values... If I

msgbox(myArr(3,3)) = 10

I can write the runnin total, just thought this was cleaner and then puzzling.

Thanks!

'let excel help
With Application
myTotal = .Sum(.Index(myArr, , 3))
End With

"stanleydgromjr" wrote:


Troubled User,

Try:

Adjust the range in the below code.




VBA Code:
--------------------





Option Explicit
Option Base 1
Sub SumArray()
Dim MyArray, a As Long, MyTotal As Double
MyTotal = 0
MyArray = *Range("A1:J10")*
For a = LBound(MyArray) To UBound(MyArray)
MyTotal = MyTotal + MyArray(a, *3*)
Next a
MsgBox "The sum of the third column is = " & Format(MyTotal, "#,##0.00")
End Sub



--------------------





Have a great day,
Stan


--
stanleydgromjr
------------------------------------------------------------------------
stanleydgromjr's Profile: 503
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=193109

http://www.thecodecage.com/forumz

.


--

Dave Peterson


 
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
How to manipulate an 2D Array into a Column Array? Joe Excel Discussion (Misc queries) 3 April 16th 07 06:30 PM
Finding a number in a column out of an array in another column cirena Excel Discussion (Misc queries) 3 April 4th 07 06:30 PM
How do I copy a data from a single column into an array and back into another column? [email protected] Excel Programming 1 February 10th 07 05:03 AM
Put 1D array into column Charlie Excel Programming 4 June 13th 06 11:20 PM
calculting stats of column array in 3D array [email protected] Excel Programming 0 February 4th 04 11:27 PM


All times are GMT +1. The time now is 05:06 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"