Thread: Formula in VB
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Formula in VB

Range("K3").Formula = "=SUM(H5:H" & MyCellNumber & ")"


--
HTH

Bob Phillips

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

"donbowyer" wrote in message
...
Excel 2003 on Win XP
The following code works:-
Range("K3").Formula = "=SUM(H5:H20)"
But I want to make the second half of the range definition
(ie the H20 bit) variable, something like:-
Range("K3").Formula = "=SUM(H5:H & MyCellNumber)"
but it fails, giving "error 2029."
I'm sure my syntax is wrong.
Would much appreciate some help with this.
--
donwb