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
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