View Single Post
 
Old 01-23-2014, 01:46 AM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Speaking as an R1C1 bigot, I snap back that he's using R1C1 because that's the natural and proper way for programmers to think. Don't let him talk you out of it, jingo. Bully for you!

But you didn't say what error message you get, and that's a critical part of the puzzle. You really must learn not only to tell us how (exactly) your code is failing, but to look at that message carefully yourself. It seems to me there's a fundamental problem in the statement; count the quote marks and see for yourself. That statement would never be accepted by the VBA editor. There has to be one more quote in your program somewhere, perhaps like this:
Code:
ActiveCell.FormulaR1C1 = "=SUMIFS(C[-8],C[-4],RC[-1],C[-15]," & numyear & "C[-7], ""<= " & tillww & """)"
Paul, the translation of that R1C1 formula depends on where ActiveCell is. Pretend it's in T50; in that case
Code:
"=SUMIFS(C[-8],C[-4],RC[-1],C[-15]," & numyear & "C[-7], ""<= " & tillww & """)"

...translates to...

"=SUMIFS(L:L,P:P,S50,E:E," & numyear & "M:M, ""<= " & tillww & """)"
If numyear=14 and tillww=5 then in the worksheet it comes out
Code:
=SUMIFS(L:L,P:P,S50,E:E,14M:M, "<= 5")
That's still wrong; there needs to be a comma between "14" and "M:M". Jingo, I think you have to change your statement to
Code:
"=SUMIFS(C[-8],C[-4],RC[-1],C[-15]," & numyear & ",C[-7],""<=" & tillww & """)"
But it'd probably be even clearer if you made the references absolute:
Code:
"=SUMIFS(C12,C16,RC19,C5," & numyear & ",C13,""<=" & tillww & """)"
Also, I think Paul's third question is a good one.
Reply With Quote