View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika Dick Kusleika is offline
external usenet poster
 
Posts: 179
Default Sum Dynamic Range - VBA

Chris

Because you're not including the parentheses, i.e. you're typing =rangetot
instead of =rangetot().

Once you put the parens in there, you will get the VALUE error because
functions can only return values. They can't Select or change properties
like FormulaR1C1.

--
Dick Kusleika
MVP - Excel
Daily Dose of Excel
http://www.dicks-blog.com

wrote:
Can anyone tell me why the end result of this function gives me the
#NAME? error in cell F2?

Function RangeTot()

Dim myLastCell As String
Dim myFirstCell As String

Selection.End(xlDown).Select

myFirstCell = ActiveCell.Address

Selection.End(xlDown).Select

myLastCell = ActiveCell.Address

Range("F2").Select
ActiveCell.FormulaR1C1 = "=sum(myFirstCell" & ":myLastCell" & ")"

End Function

TIA,

Chris