Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input "sum()" in excel through VB

Status
Not open for further replies.

Bullsandbears123

Technical User
Feb 12, 2003
291
US
I have the controls set to input my formula into an excel spreadsheet, but my formula does not format correct once set.
I am using this code where brow=beginning row and erow=ending row....
brow=1
erow=5

ActiveCell.FormulaR1C1 = "=SUM(S" & brow & ":" & "S" & erow & ")"

I end up getting "=Sum('S1':'S5')" instead of..
"=sum(S1:S5)"

any ideas?

 
Try

Dim brow As Integer
Dim erow As Integer

in your code.

This should help

dyarwood
 
Maybe try setting the string as follows

cal = "=SUM(S" & brow & ":S" & erow & ")"

Then

ActiveCell.FormulaR1C1 = cal

That might get round the problem

dyarwood
 
Nope, makes no difference, there is something wrong in the way I'm doing it. I think I may need to use cell(S,brow) or some thing
Please any ideas are appreciated.

Thanks
 
Instead of using the FormulaR1C1 property, try using the Formula Property like:

ActiveCell.Formula = "=SUM(S" & brow & ":S" & erow & ")"

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top