Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default SUMPRODUCT in macro

Here is what i have

buttonClick()
'ommited defined variables and other useless stuff

CurrentSheet.Cells(CurrentRow, 6).Formula = "=SUMPRODUCT(B2:E2{1,3,2,3})"

What i would like is the range in the formula to increase as the Current row
increases so =SUMPRODUCT(B3:E3{1,3,2,3}) and so on down the table

In Short the 6th column of every row needs a SUMPRODUCT function for the 3rd
through 5th coulmn

i think i have to define a variable but not sure here.

Somthing like =SUMPRODUCT(B(i):E(i){1,3,2,3}) maybe?
any help would be great.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default SUMPRODUCT in macro

i = 5
"=SUMPRODUCT(B" & i & ":E" & i & "{1,3,2,3})"

"Office_Novice" wrote:

Here is what i have

buttonClick()
'ommited defined variables and other useless stuff

CurrentSheet.Cells(CurrentRow, 6).Formula = "=SUMPRODUCT(B2:E2{1,3,2,3})"

What i would like is the range in the formula to increase as the Current row
increases so =SUMPRODUCT(B3:E3{1,3,2,3}) and so on down the table

In Short the 6th column of every row needs a SUMPRODUCT function for the 3rd
through 5th coulmn

i think i have to define a variable but not sure here.

Somthing like =SUMPRODUCT(B(i):E(i){1,3,2,3}) maybe?
any help would be great.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default SUMPRODUCT in macro

if i = 5

it doesn't do what i need, I want the variable to vary if i assign it a
value i wont cahne with the current row.

"Joel" wrote:

i = 5
"=SUMPRODUCT(B" & i & ":E" & i & "{1,3,2,3})"

"Office_Novice" wrote:

Here is what i have

buttonClick()
'ommited defined variables and other useless stuff

CurrentSheet.Cells(CurrentRow, 6).Formula = "=SUMPRODUCT(B2:E2{1,3,2,3})"

What i would like is the range in the formula to increase as the Current row
increases so =SUMPRODUCT(B3:E3{1,3,2,3}) and so on down the table

In Short the 6th column of every row needs a SUMPRODUCT function for the 3rd
through 5th coulmn

i think i have to define a variable but not sure here.

Somthing like =SUMPRODUCT(B(i):E(i){1,3,2,3}) maybe?
any help would be great.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default SUMPRODUCT in macro

There are two methods

For RowCount = 1 to 10
Range("A" & Rowcount).formula = _
"=SUMPRODUCT(B" & RowCount & ":E" & Rowcount & "{1,3,2,3})"
Next RowCount

or put the formula in one cell and copy the cell
Range("A1").formula = _
"=SUMPRODUCT(B" & RowCount & ":E" & Rowcount & "{1,3,2,3})"
Range("A1").copy destination:=Range("A2:A10")

copying a cell with a formula in VBA is like copying the formula on the
worksheet, the rows will change.


"Office_Novice" wrote:

if i = 5

it doesn't do what i need, I want the variable to vary if i assign it a
value i wont cahne with the current row.

"Joel" wrote:

i = 5
"=SUMPRODUCT(B" & i & ":E" & i & "{1,3,2,3})"

"Office_Novice" wrote:

Here is what i have

buttonClick()
'ommited defined variables and other useless stuff

CurrentSheet.Cells(CurrentRow, 6).Formula = "=SUMPRODUCT(B2:E2{1,3,2,3})"

What i would like is the range in the formula to increase as the Current row
increases so =SUMPRODUCT(B3:E3{1,3,2,3}) and so on down the table

In Short the 6th column of every row needs a SUMPRODUCT function for the 3rd
through 5th coulmn

i think i have to define a variable but not sure here.

Somthing like =SUMPRODUCT(B(i):E(i){1,3,2,3}) maybe?
any help would be great.


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 macro Kim Excel Discussion (Misc queries) 2 September 21st 09 04:36 PM
use LIKE within sumproduct in macro, possible? [email protected] Excel Programming 3 August 31st 06 02:42 AM
macro with SUMPRODUCT help [email protected] Excel Programming 8 August 30th 06 10:27 PM
Macro wtih sumproduct 2 help [email protected] Excel Programming 2 August 30th 06 12:54 AM
How to use SUMPRODUCT in macro? Tarek Excel Programming 6 April 27th 05 07:03 AM


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