Pb with application.worksheet.product

vadius

Board Regular
Joined
Jul 5, 2011
Messages
70
Hi there
I have a problem with the Application.WorksheetFunction.Produc
I am tryiong to build a macro that gives you the product of the three previous cells in one cell. (on a line). The problem is I don't know how to specify the range of cells I want the macro to calculate the product.
then I an doing this for every 4th column. The first column is a column of date (=column A), and then I have 3 coloumns of data (Column B,C,D) I want the product in the 4th column (line by line) (Column E), then I have again 3 columns of data (Columns F, G,H) , and I want the macro to get the product of those three values in column I, etc etc....
Thanks for your help


Below the code

Code:
Sub moyenne()
Dim i, j As Integer
Dim n As Variant
Set plage = Range(Cells(2, 5), Cells(2, 5).End(xlDown))
'count the number of cells in the table
n = WorksheetFunction.Count(plage)
For j = 5 To 81 Step 4
     For i = 2 To n
     'try to calculate the product column b * column b * column c for each row
    
     Range(Cells(i, j), Cells(i, j)).Select
     myrange = Range(ActiveCell, ActiveCell.Offset(0, -3)).Select
     Range(Cells(i, j), Cells(i, j)).Value = Application.Worksheet.Product(myrange)
     
     Next i
     
Next j
     
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top