View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
atpgroups atpgroups is offline
external usenet poster
 
Posts: 40
Default Refer to Column with a variable

On 7 May, 22:22, straightedge32
wrote:

Set myRange = wrksht.Range(wrksht.Cells(nCurrRow, 8), wrksht.Cells(nCurrRow,
16)).... etc.

But how do I use this range to calculate a value or put it in a formula?

So I'd like cell (nCurrRow, 17) for instance to be the average of myRange. *


wrksht.cells(nCurrRow,17).Value =
Application.WorkSheetFunctions.Average(myRange).Va lue

Should do the trick.

Don't forget the .Value bit. It is not entirely necessary for .Value
as that is the default property, but it makes it clear you are not
trying to redefine a range but instead work on the data in that
range.