ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formula in VB (https://www.excelbanter.com/excel-programming/382326-formula-vbulletin.html)

donbowyer

Formula in VB
 
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

Bob Phillips

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




Tom Ogilvy

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

--
Regards,
Tom Ogilvy


"donbowyer" wrote:

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


donbowyer

Formula in VB
 
So simple when you know, or perhaps I'm just tired!!
Thanks guys
Don B
--
donwb


"Bob Phillips" wrote:

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






All times are GMT +1. The time now is 12:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com