View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_18_] Patrick Molloy[_18_] is offline
external usenet poster
 
Posts: 1
Default Sumif in VB Code

you can't use "cells" within a worksheet formula


Worksheets(2).Cells(Counter, 8).FormulaR1C1 =
"=SUMIF(Timesheet!R5C8:R5C256)),1,Timesheet!R" & _
counter & "C8:R" & counter & "C256))"


-----Original Message-----
Can anyone tell me what is wrong with this bit of code

which is in a loop
with a counter variable?
I am trying to define a formula on worksheet(2) based

upon ranges in a
worksheet called "Timesheet" Everywhere else I have

always used FormulaR1C1
style but that does'nt fit in this case.


Worksheets(2).Cells(Counter, 8).Formula =
"=SUMIF(Timesheet!(Cells(5,8),Cells(5,256)),1,Tim esheet!

(Cells(Counter,8),Ce
lls(counter,256))"



.