Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default sumproduct or other way in vba, help and thanks

dear all

a question about sumproduct function, in a sheet
A B C
1) 2 0 1
2) 4 5 6
3) 7 8 9
4) 10 11 12

Now I can use 2 sumproduct to make calculation,like
A1*C1+A2*C2 in one sumproduct
A4*C4 in another sumproduct
then I add result together.

My question is, is there anyway to make a formula
A1*C1+A2*C2+A4*C4. I could choose different array then define in more detail
because sumproduct ask all array should have same dimension.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default sumproduct or other way in vba, help and thanks

You can just use SUM

=SUM(A1*C1,A2*C2,A4*C4)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"jiang" wrote in message
...
dear all

a question about sumproduct function, in a sheet
A B C
1) 2 0 1
2) 4 5 6
3) 7 8 9
4) 10 11 12

Now I can use 2 sumproduct to make calculation,like
A1*C1+A2*C2 in one sumproduct
A4*C4 in another sumproduct
then I add result together.

My question is, is there anyway to make a formula
A1*C1+A2*C2+A4*C4. I could choose different array then define in more

detail
because sumproduct ask all array should have same dimension.

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default sumproduct or other way in vba, help and thanks

Thanks, Bob

But it couldn't really solve my problem because I'm trying to make input
data easier, what I really want to know is whether a function could let user
select arrays and get calculation directly, instead of having to type formula.

My example is too simple, the real situation is that user might have to make
very long formula, and sometimes it's easy to make mistakes. It's much easier
if people just select array and ger result.

Anyway, thanks again for your prompt reply.
jiang

"Bob Phillips" wrote:

You can just use SUM

=SUM(A1*C1,A2*C2,A4*C4)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"jiang" wrote in message
...
dear all

a question about sumproduct function, in a sheet
A B C
1) 2 0 1
2) 4 5 6
3) 7 8 9
4) 10 11 12

Now I can use 2 sumproduct to make calculation,like
A1*C1+A2*C2 in one sumproduct
A4*C4 in another sumproduct
then I add result together.

My question is, is there anyway to make a formula
A1*C1+A2*C2+A4*C4. I could choose different array then define in more

detail
because sumproduct ask all array should have same dimension.

Thanks in advance.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default sumproduct or other way in vba, help and thanks

This might work for you

Sub SumResult()
Dim rng1 As Range
Dim rng2 As Range
Dim cell As Range
Dim cRowOff As Long
Dim cColOff As Long
Dim tmp

Set rng1 = Application.InputBox("Select all cells in first range",
Type:=8)
Set rng2 = Application.InputBox("Select just the first cell in second
range", Type:=8)
cRowOff = rng2.Cells(1, 1).Row - rng1.Cells(1, 1).Row
cColOff = rng2.Cells(1, 1).Column - rng1.Cells(1, 1).Column
For Each cell In rng1
tmp = tmp + (cell.Value * cell.Offset(cRowOff, cColOff).Value)
Next cell

Set cell = Application.InputBox("Now select cell to put result",
Type:=8)
cell.Value = tmp

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"jiang" wrote in message
...
Thanks, Bob

But it couldn't really solve my problem because I'm trying to make input
data easier, what I really want to know is whether a function could let

user
select arrays and get calculation directly, instead of having to type

formula.

My example is too simple, the real situation is that user might have to

make
very long formula, and sometimes it's easy to make mistakes. It's much

easier
if people just select array and ger result.

Anyway, thanks again for your prompt reply.
jiang

"Bob Phillips" wrote:

You can just use SUM

=SUM(A1*C1,A2*C2,A4*C4)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"jiang" wrote in message
...
dear all

a question about sumproduct function, in a sheet
A B C
1) 2 0 1
2) 4 5 6
3) 7 8 9
4) 10 11 12

Now I can use 2 sumproduct to make calculation,like
A1*C1+A2*C2 in one sumproduct
A4*C4 in another sumproduct
then I add result together.

My question is, is there anyway to make a formula
A1*C1+A2*C2+A4*C4. I could choose different array then define in more

detail
because sumproduct ask all array should have same dimension.

Thanks in advance.






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
Sumproduct with Condition OR Sumproduct with ADDRESS function - HE gholly Excel Discussion (Misc queries) 2 September 28th 09 05:07 PM
Conditional SUMPRODUCT or SUMPRODUCT with Filters Ted M H Excel Worksheet Functions 4 August 14th 08 07:50 PM
sumproduct? sumif(sumproduct)? David Excel Worksheet Functions 3 July 13th 07 07:06 PM
Help with SUMPRODUCT Aaron Excel Discussion (Misc queries) 4 January 24th 06 11:46 PM
SUMPRODUCT ??? frustratedwthis Excel Discussion (Misc queries) 5 January 23rd 06 08:09 PM


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

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"