Rolling 12 moth formula

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

I would like to create a formula in Col A that would go out 12 columns (B -
M) and then be able to insert a new column B and have the formula remain
=Sum(B1:M1) and not change to =Sum(C1:N1). Is that possible?
 
Yes, simply change the formula in column A to
=SUM($B1:$M1)
that'll keep the column references from changing even when you insert the
new column B.
 
The formula still changes when I do that.

JLatham said:
Yes, simply change the formula in column A to
=SUM($B1:$M1)
that'll keep the column references from changing even when you insert the
new column B.
 
Probably what I get for writing without testing. Your (and Mike H's)
Indirect would seem to work much, much better. Glad I got caught in my error
early on.

But seems it OUGHT to work that way. If I I referred to Range("$B1:$M1") in
code it sure as hell wouldn't change I don't care how many rows or columns
you inserted, I'd get the value in cells B1 through M1 regardless.
 
If I I referred to Range("$B1:$M1") in
code it sure as hell wouldn't change I don't care how many rows or columns
you inserted, I'd get the value in cells B1 through M1 regardless.

And I think we can all agree you would but likewise if you inserted Rows the
1 wouldn't change to 2 either despite it being relative. I can see the point
of the dollar sign in Vb in things like 'activecell.formula ="=sum($A...' etc
but what is the purpose or point of $ in VB in instances like the one you
note?

Mike
 
Well, my big question is do $'s actually anchor the moth's to excel? How did
the OP actually get the 12 moth's into excel, cuz I think that would be a far
more difficult question.

:)
 
Mike, as in the example I gave - the $ serves no useful purpose in VBA.
However, if setting up a formula to be written to a cell, it would.
Bottom line here is that at the time I wrote my initial response, apparently
my body was contorted into a rather uncomfortable position and my head was in
a rather dark, dank location! However, thanks to John C, I have a plausible
excuse: had we been working with moths and not months or cells on an Excel
worksheet, my answer may have actually worked ;).
 

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

Back
Top