View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Programmatically add worksheet function

Worksheets("Sheet2").Range("C1").Value = "=SUM(C2:C" & LastRow & ")"


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Office_Novice" wrote in message
...
I haven't tried this before now and i am having a little trouble.

This is what i have:
Worksheets("Sheet2").Range("C1").Value = "=SUM(C2:C5000)"

And it works ok, But i wont always know the range. I need something like:

Worksheets("Sheet2").Range("C1").Value = "=SUM(C2:C" & LastRow)"

But i tried that and the function didn't recognize my variable. Any help
would be great.