Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Variable in formula

I have the following formula
=AVERAGE(OFFSET(BM51,-34,0,-12,1))

Next month, I will copy it one cell to the right and adjust the -34 to -35.
Is it possible through VBA to set the "-34" as a variable when it copies the
formula, and enter the new formula with something like "MyVariable -1". In
other words have it look to see what the current value is now, copy it to the
next cell and adjust the rows accordingly.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Variable in formula

=AVERAGE(OFFSET(BM51,-33-COLUMN(A1),0,-12,1))

when you copy it next month the A1 will update to B1, so ,-33-COLUMN(A1),
will become ,-33-COLUMN(B1), which then evaluates to -35

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"StephanieH" wrote in message
...
I have the following formula
=AVERAGE(OFFSET(BM51,-34,0,-12,1))

Next month, I will copy it one cell to the right and adjust the -34

to -35.
Is it possible through VBA to set the "-34" as a variable when it copies

the
formula, and enter the new formula with something like "MyVariable -1".

In
other words have it look to see what the current value is now, copy it to

the
next cell and adjust the rows accordingly.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Variable in formula

Perfect.

Thanks.

"Bob Phillips" wrote:

=AVERAGE(OFFSET(BM51,-33-COLUMN(A1),0,-12,1))

when you copy it next month the A1 will update to B1, so ,-33-COLUMN(A1),
will become ,-33-COLUMN(B1), which then evaluates to -35

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"StephanieH" wrote in message
...
I have the following formula
=AVERAGE(OFFSET(BM51,-34,0,-12,1))

Next month, I will copy it one cell to the right and adjust the -34

to -35.
Is it possible through VBA to set the "-34" as a variable when it copies

the
formula, and enter the new formula with something like "MyVariable -1".

In
other words have it look to see what the current value is now, copy it to

the
next cell and adjust the rows accordingly.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable within a formula Tom Melosi Excel Worksheet Functions 4 August 21st 07 04:07 AM
Using a variable in a VBA formula Colin Vicary Excel Discussion (Misc queries) 3 November 8th 05 11:39 AM
Using a variable in a formula Noah Excel Programming 3 October 28th 05 04:39 PM
Help With a Variable Formula jdurrmsu Excel Programming 1 September 16th 05 04:22 PM
Using a variable in formula DtTall Excel Programming 2 August 15th 05 04:23 PM


All times are GMT +1. The time now is 07:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"