Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Sum not working on Array

I have several checkboxes. I pass the value of the checks
to an array called ChkbxArray. The array has 4 colums.
Columns 1 to 3 have Integers in them. I just added the
following to column 4 of the array

Set ChkbxArray(0, 4) = ActiveSheet.Comments
Set ChkbxArray(1, 4) = ActiveSheet.UsedRange
Set ChkbxArray(2, 4) = ActiveSheet.UsedRange
Set ChkbxArray(3, 4) = ActiveSheet.UsedRange
Set ChkbxArray(4, 4) = ActiveSheet.UsedRange
Set ChkbxArray(5, 4) = ActiveSheet.UsedRange

Upon doing this, the following line of code failed. I am
assuming it failed as the entire array has been put into
the sum. Even though I only want column 1 summed. What
can I do ensure that I can sum column 1 in this array?

ChkbxArraySum = Application.WorksheetFunction.Sum
(Application.Index(ChkbxArray, 0, 1))

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sum not working on Array

That would be the way to do it. However, since you are using a
worksheetfunction, possibly the index function can't deal with array items
that have objects stored in them. That certainly isn't something that would
be encountered in a worksheet.

Looks like you will need to roll your own

Dim Tot as Double
for i = lbound(ChkbxArray,1) to ubound(ChkbxArray,1)
if isnumeric(ChkbxArray(i,lbound(ChkbxArray,2)) then
tot = tot + ChkbxArray(i,lbound(ChkbxArray,2))
end if
Next

--
Regards,
Tom Ogilvy

"ExcelMonkey" wrote in message
...
I have several checkboxes. I pass the value of the checks
to an array called ChkbxArray. The array has 4 colums.
Columns 1 to 3 have Integers in them. I just added the
following to column 4 of the array

Set ChkbxArray(0, 4) = ActiveSheet.Comments
Set ChkbxArray(1, 4) = ActiveSheet.UsedRange
Set ChkbxArray(2, 4) = ActiveSheet.UsedRange
Set ChkbxArray(3, 4) = ActiveSheet.UsedRange
Set ChkbxArray(4, 4) = ActiveSheet.UsedRange
Set ChkbxArray(5, 4) = ActiveSheet.UsedRange

Upon doing this, the following line of code failed. I am
assuming it failed as the entire array has been put into
the sum. Even though I only want column 1 summed. What
can I do ensure that I can sum column 1 in this array?

ChkbxArraySum = Application.WorksheetFunction.Sum
(Application.Index(ChkbxArray, 0, 1))

Thanks



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
array not working James Excel Discussion (Misc queries) 1 October 16th 09 05:45 PM
3d array not working D Excel Worksheet Functions 3 November 2nd 07 03:36 PM
Array fomrula not working... NWO Excel Worksheet Functions 5 March 1st 07 09:56 PM
CountIf Array not working NWO Excel Discussion (Misc queries) 1 March 1st 07 07:48 PM
Array formula not working Alex Excel Worksheet Functions 3 June 15th 05 12:28 AM


All times are GMT +1. The time now is 09:04 AM.

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

About Us

"It's about Microsoft Excel"