FormulaArray

T

Troy

Hi!

I have the following code which inserts formula in multiple cells:

RC=RowColumn LC=LastColumn SC=StartColumn

myformula = "= SUM(IF(LEN(R" & RC & "C" & SC & ":R" & RC & "C" & LC &
")=1,IF(LEFT(R" & RC & "C" & SC & ":R" & RC & "C" & LC & ")=" & """" &
Mid(MyText, Counter - 6, 1) & """" & ",8.5,0),0)) + SUM(IF(R" & RC & "C" &
SC & ":R" & RC & "C" & LC & "=" & """" & Mid(MyText, Counter - 6, 1) & "!"""
& ",8,0))" & " & " & """ / """ & " & " & "SUM(IF(LEN(R" & RC & "C" & SC &
":R" & RC & "C" & LC & ">1 ),IF(LEFT(R" & RC & "C" & SC & ":R" & RC & "C" &
LC & ") =" & """" & Mid(MyText, Counter - 6, 1) & """" &
",IF(ISNUMBER(VALUE(MID(R" & RC & "C" & SC & ":R" & RC & "C" & LC &
",2,LEN(R" & RC & "C" & SC & ":R" & RC & "C" & LC & ")-1))),VALUE(MID(R" &
RC & "C" & SC & ":R" & RC & "C" & LC & ",2,LEN(R" & RC & "C" & SC & ":R" &
RC & "C" & LC & ")-1)),0),0)))"

I can insert it OK with the following and manually change it to an Array
Formula:

Range(Cells(RC, LC + Counter), Cells(RC, LC + Counter)).Formula = myformula

However when I use the following I get an error message:
"Runtime error 1004" "Unable to set the FormulaArray property of the Range
class."

Range(Cells(RC, LC + Counter), Cells(RC, LC + Counter)).FormulaArray =
myformula

Any help appreciated

Troy
 

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