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

Is there any way to use a variable in a formula? I have
two workbooks that I need to add together each month.
Rather than go in and use find replace each month to
change the formula I would like the formula to
automatically do it. Example - two workbooks WB1 and
WB2, formula for this month = +A1+'[WB2.xls]A1. Next
month WB2 will be WB3, so I need a formula in WB1 that
will be "+A1+'[WB3.xls]A1" . In WB1 cell A2 I have the
corresponding month so in month 3 it would be 3 etc. So
the formula that I am trying to create is "=A1+(WB
&"A2".xls]A1". Obviously it does not work.

Any ideas would be very much appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Formula Variable

Hi
if the other workbook is OPEN try
=A1+INDIRECT("'[WB" & A2 & ".xls]sheetname'!A1")
i A2 stores your 'variable'. You have to adapt the worksheetname

--
Regards
Frank Kabel
Frankfurt, Germany
"Ronbo" schrieb im Newsbeitrag
...
Is there any way to use a variable in a formula? I have
two workbooks that I need to add together each month.
Rather than go in and use find replace each month to
change the formula I would like the formula to
automatically do it. Example - two workbooks WB1 and
WB2, formula for this month = +A1+'[WB2.xls]A1. Next
month WB2 will be WB3, so I need a formula in WB1 that
will be "+A1+'[WB3.xls]A1" . In WB1 cell A2 I have the
corresponding month so in month 3 it would be 3 etc. So
the formula that I am trying to create is "=A1+(WB
&"A2".xls]A1". Obviously it does not work.

Any ideas would be very much appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Formula Variable


-----Original Message-----
Hi
if the other workbook is OPEN try
=A1+INDIRECT("'[WB" & A2 & ".xls]sheetname'!A1")
i A2 stores your 'variable'. You have to adapt the

worksheetname

--
Regards
Frank Kabel
Frankfurt, Germany
"Ronbo" schrieb im

Newsbeitrag
...
Is there any way to use a variable in a formula? I

have
two workbooks that I need to add together each month.
Rather than go in and use find replace each month to
change the formula I would like the formula to
automatically do it. Example - two workbooks WB1 and
WB2, formula for this month = +A1+'[WB2.xls]A1. Next
month WB2 will be WB3, so I need a formula in WB1 that
will be "+A1+'[WB3.xls]A1" . In WB1 cell A2 I have the
corresponding month so in month 3 it would be 3 etc.

So
the formula that I am trying to create is "=A1+(WB
&"A2".xls]A1". Obviously it does not work.

Any ideas would be very much appreciated.


.
Thanks for the info, however the worksheet is not open.

Any other Ideas?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Formula Variable

Hi
If the other workbook is closed try the following:
have a look at the Add-In MOREFUNC.XLL
(http://longre.free.fr/english)
use the function INDIRECT.EXT.e.g.
=INDIRECT.EXT("''C:\Documents and Settings\" & cell_ref1 &
"\MyDocuments\My folder\[" & cell_ref2 & cell_ref3 & ".xls]Expense
Statement'!$F$2")
thats is just replace your function INDIRECT with INDIRECT.EXT and add
the path information

you may also have a look at the following thread (describing further
alternatives for accessing closed workbooks): http://tinyurl.com/2c62u

--
Regards
Frank Kabel
Frankfurt, Germany
"Ronbo" schrieb im Newsbeitrag
...

-----Original Message-----
Hi
if the other workbook is OPEN try
=A1+INDIRECT("'[WB" & A2 & ".xls]sheetname'!A1")
i A2 stores your 'variable'. You have to adapt the

worksheetname

--
Regards
Frank Kabel
Frankfurt, Germany
"Ronbo" schrieb im

Newsbeitrag
...
Is there any way to use a variable in a formula? I

have
two workbooks that I need to add together each month.
Rather than go in and use find replace each month to
change the formula I would like the formula to
automatically do it. Example - two workbooks WB1 and
WB2, formula for this month = +A1+'[WB2.xls]A1. Next
month WB2 will be WB3, so I need a formula in WB1 that
will be "+A1+'[WB3.xls]A1" . In WB1 cell A2 I have the
corresponding month so in month 3 it would be 3 etc.

So
the formula that I am trying to create is "=A1+(WB
&"A2".xls]A1". Obviously it does not work.

Any ideas would be very much appreciated.


.
Thanks for the info, however the worksheet is not open.

Any other Ideas?


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 formula LP23294 Excel Worksheet Functions 4 October 27th 09 07:46 PM
Variable VBA Max Formula Gizmo Excel Discussion (Misc queries) 2 June 6th 08 06:12 AM
DDE formula with variable Bruce Excel Worksheet Functions 0 November 16th 07 09:03 AM
Using a second variable within a formula... Ed Anton Excel Discussion (Misc queries) 2 February 18th 05 11:51 AM
Variable to formula. russell \(skmr3\) Excel Programming 1 July 30th 03 07:11 AM


All times are GMT +1. The time now is 12:11 AM.

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"