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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with inserting formula in cell. VBA

Status
Not open for further replies.

tekfangr

Programmer
Nov 25, 2005
3
CH
Hello to all.

I can't get to execute this code without an error (1004):

Code:
Private Sub CommandButton3_Click()
Dim j As Variant
Dim x As Variant
Dim i As Variant
x = "="
For i = 1 To Range("p1").Value
    j = j + "SUM(B" & 28 + i & ")"
Next i
MsgBox (x)
j = x & j
Range("q1").Formula = j
End Sub

What am i missing?

Many thanks for your help
 
Not quite sure what you're doing but doesn't this do it?

Code:
Range("q1").Formula = "=SUM(B28:B" & 28 + Range("p1").Value & ")"
 




Hi,

What's your FUNCTIONAL objective here, in plain English?

Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 
Sorry, not only i pasted an erronous, but i also not left any explanation (by the way english is not my native language, so sorry for the mistakes).
Please ignore the post, i found my answer...
Thanks for your help, both of you!
 





If you found an answer, it would be helpful to other members, if you would post your solution.

Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top