1
votes

I would like to get the product of values of a range of cells in excel, using VBA.

I got a selection e.g.: (that works)

ActiveSheet.Range(Cells(i, j), Cells(i, z)).Select

I would like to put the product of a range in another cell but this is not working:

'Range("X10").Formula = "=PRODUCT(Range(Cells(i, j),Cells(i, z)))"

Help is really appreciated, thanks in advance!

1
You'd need an worksheet reference in the product formula. Try (Range(Cells(i,j),Cells(i,)).Address & ":" & Range(Cells(i,j),Cells(i,z)).Address. (Not doing this with Excel open - hope I've got the parentheses right)chuff

1 Answers

2
votes
Range("X10").Formula = "=PRODUCT(" & Cells(i, j).Address & ":" & Cells(i, z).Address & ")"