Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing a variable as an argument to a function
is it possible to use a variable as an argument to a
function? for example: rng1.formula = "=sum(rng2)". im trying to write a macro that places the sum formula in the worksheet just below the data. i dont know how many rows of data there is, so I cant hard code the sum range. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing a variable as an argument to a function
Drew,
Assuming that rng2 is a range object, then rng1.formula = "=SUM(" & rng2.address & ")" -- HTH ------- Bob Phillips ... looking out across Poole Harbour to the Purbecks "Drew" wrote in message ... is it possible to use a variable as an argument to a function? for example: rng1.formula = "=sum(rng2)". im trying to write a macro that places the sum formula in the worksheet just below the data. i dont know how many rows of data there is, so I cant hard code the sum range. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing a variable as an argument to a function
Drew,
If your data is in column A Dim lrow As Long lrow = Cells(Rows.COUNT, "A").End(xlUp).Row will determine the lastrow. than Cells(lrow+1,1).FormulaR1C1 = "=Sum(R1C1:R" & lrow & "C1)" should put the sum one row below the last entry in the column. steve "Drew" wrote in message ... is it possible to use a variable as an argument to a function? for example: rng1.formula = "=sum(rng2)". im trying to write a macro that places the sum formula in the worksheet just below the data. i dont know how many rows of data there is, so I cant hard code the sum range. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
passing a variable as an argument to a function
beautiful, thanks. i knew there had to be a way.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Passing a range name as an argument to the Index Function | Excel Discussion (Misc queries) | |||
Passing a UDF as an argument to a UDF | Excel Discussion (Misc queries) | |||
Passing Variable to LINEST | Excel Worksheet Functions | |||
Passing an argument to a quote | Excel Programming | |||
Passing an argument to a quote | Excel Programming |