Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula in a range which varies in size
Hi I need code to be able to scroll through the cells in a range of variable size and add the values in the in columns N and O and place the result in column Q for each row in the range. The number of rows varies each time. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula in a range which varies in size
How do you determine the range of rows?
Option Explicit Sub testme() Dim FirstRow As Long Dim LastRow As Long With Worksheets("sheet1") FirstRow = 2 'headers in row 1 and row 2 starts the data LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row With .Range(.Cells(FirstRow, "Q"), .Cells(LastRow, "Q")) .FormulaR1C1 = "=SUM(RC[-3]:RC[-2])" '.Value = .Value End With End With End Sub This actually puts a formula in that range. If you want the value, then uncomment that ".value = .value" line. And I used column A to determine the last row to populate. Alan M wrote: Hi I need code to be able to scroll through the cells in a range of variable size and add the values in the in columns N and O and place the result in column Q for each row in the range. The number of rows varies each time. Thanks -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can a range be copied if it varies in size? | Excel Discussion (Misc queries) | |||
Setting a range that varies | Excel Programming | |||
Sum of a range that varies | Excel Discussion (Misc queries) | |||
Macro to find a range that varies. | Excel Programming | |||
Insert SUM Formula using VBA (Range Varies) | Excel Programming |