Formula Cell Error

S

swiftcode

Hi all,

i have a problem with the following code, would appreciate if anyone can
give me some help on this. Basically everything works fine except for this
line:

Cells(i, 12).FormulaR1C1 = "=SUM(J" & StartCount & ":J" & EndCount & ")"

The cell will reflect "=SUM('J2':'J3')" instead of "=SUM(J2:J3)".

---------------------------------------------------------------------------------------------
Sub Test()

For i = 2 To 100 Step 1
Cells(i, 1).Select
If Cells(i, 1).Interior.ColorIndex = 2 Then
StartCount = ActiveCell.Row

ElseIf Cells(i, 1).Interior.ColorIndex = 37 Then
EndCount = ActiveCell.Row
Cells(i, 12).FormulaR1C1 = "=SUM(J" & StartCount & ":J" & EndCount & ")"

End If
Next i

End Su
----------------------------------------------------------------------------------------

Thanks in advance

Rgds
Ray
 
J

Jacob Skaria

Try the below. Your formula is not in R1C1 syntax

Cells(i, 12).Formula = "=SUM(J" & StartCount & ":J" & EndCount & ")"

If this post helps click Yes
 
S

Stefi

Omit R1C1:

Cells(i, 12).Formula = "=SUM(J" & StartCount & ":J" & EndCount & ")"

Regards,
Stefi

„swiftcode†ezt írta:
 
S

swiftcode

Hi Guys,

Thank you very much for all you solutions, it solved my problem.

You all have a great week ahead.

Rgds
Ray
 
S

Stefi

You are welcome! Thanks for the feedback!

Sorry for the late answer but I've just now realized that my e-mail
notification doesn't work.


--
Regards!
Stefi



„swiftcode†ezt írta:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top