Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default variable inside a formula?

This is what I'm trying to do.

I have a formula in a cell A2 that reads as follows:
='F:\Job Info\PAY APPLICATION\[blank.xls]Pay App 1'!L13

Is there a way to have the user type in the real name of the file, in say
another cell or a text box(on a form) that will enter itself into the above
formula where blank.xls is?
So when the user types in File1.xls as the name of the file in cell A1, the
formula in cell A2 adjusts to read:
='F:\Job Info\PAY APPLICATION\[File1.xls]Pay App 1'!L13

Can be a marco or click action on a button using VB. Any ideas or a better
way to go about this?
Thanks.

Phil


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default variable inside a formula?

In cell A1

=INDIRECT("'F:\Job Info\PAY APPLICATION\["&A1&"]Pay App 1'!L13")


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Phil" wrote in message
...
This is what I'm trying to do.

I have a formula in a cell A2 that reads as follows:
='F:\Job Info\PAY APPLICATION\[blank.xls]Pay App 1'!L13

Is there a way to have the user type in the real name of the file, in say
another cell or a text box(on a form) that will enter itself into the

above
formula where blank.xls is?
So when the user types in File1.xls as the name of the file in cell A1,

the
formula in cell A2 adjusts to read:
='F:\Job Info\PAY APPLICATION\[File1.xls]Pay App 1'!L13

Can be a marco or click action on a button using VB. Any ideas or a better
way to go about this?
Thanks.

Phil




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default variable inside a formula?

Very cool. I didn't know about the INDIRECT function. I opened the excel
help and looked into it more and unfortunately I can't use it because the
info that the formula pulls over is in an external workbook and in order for
the INDIRECT to update the external workbook has to be open, otherwise I get
the #ref error. If I open the other workbook, then it works great. This is
going to be a "master list" of current jobs that reference multiple other
workbooks, so having to open them all for the function to work isn't going
to work. Sorry I didn't let you know the info comes from an external
workbook. But thanks for the response and the new function I learned. I'm
sure I'll use it in the future.

Bob Phillips wrote:
In cell A1

=INDIRECT("'F:\Job Info\PAY APPLICATION\["&A1&"]Pay App 1'!L13")



"Phil" wrote in message
...
This is what I'm trying to do.

I have a formula in a cell A2 that reads as follows:
='F:\Job Info\PAY APPLICATION\[blank.xls]Pay App 1'!L13

Is there a way to have the user type in the real name of the file,
in say another cell or a text box(on a form) that will enter itself
into the above formula where blank.xls is?
So when the user types in File1.xls as the name of the file in cell
A1, the formula in cell A2 adjusts to read:
='F:\Job Info\PAY APPLICATION\[File1.xls]Pay App 1'!L13

Can be a marco or click action on a button using VB. Any ideas or a
better way to go about this?
Thanks.

Phil



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default variable inside a formula?

No problem Phil, just add it to the toolbox<g

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Phil" wrote in message
...
Very cool. I didn't know about the INDIRECT function. I opened the excel
help and looked into it more and unfortunately I can't use it because the
info that the formula pulls over is in an external workbook and in order

for
the INDIRECT to update the external workbook has to be open, otherwise I

get
the #ref error. If I open the other workbook, then it works great. This is
going to be a "master list" of current jobs that reference multiple other
workbooks, so having to open them all for the function to work isn't going
to work. Sorry I didn't let you know the info comes from an external
workbook. But thanks for the response and the new function I learned. I'm
sure I'll use it in the future.

Bob Phillips wrote:
In cell A1

=INDIRECT("'F:\Job Info\PAY APPLICATION\["&A1&"]Pay App 1'!L13")



"Phil" wrote in message
...
This is what I'm trying to do.

I have a formula in a cell A2 that reads as follows:
='F:\Job Info\PAY APPLICATION\[blank.xls]Pay App 1'!L13

Is there a way to have the user type in the real name of the file,
in say another cell or a text box(on a form) that will enter itself
into the above formula where blank.xls is?
So when the user types in File1.xls as the name of the file in cell
A1, the formula in cell A2 adjusts to read:
='F:\Job Info\PAY APPLICATION\[File1.xls]Pay App 1'!L13

Can be a marco or click action on a button using VB. Any ideas or a
better way to go about this?
Thanks.

Phil





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default variable inside a formula?

Phil,
The following macro in a standard module should get you started.

Sub FormulaUpdate()
Dim FileName, Fmla
FileName = Range("A1")
Fmla = "F:\Job Info\PAY APPLICATION\[" & FileName & "]Pay App 1'!L13"
Range("A2") = Fmla
End Sub

Regards,
Don

"Phil" wrote in message
...
This is what I'm trying to do.

I have a formula in a cell A2 that reads as follows:
='F:\Job Info\PAY APPLICATION\[blank.xls]Pay App 1'!L13

Is there a way to have the user type in the real name of the file, in say
another cell or a text box(on a form) that will enter itself into the

above
formula where blank.xls is?
So when the user types in File1.xls as the name of the file in cell A1,

the
formula in cell A2 adjusts to read:
='F:\Job Info\PAY APPLICATION\[File1.xls]Pay App 1'!L13

Can be a marco or click action on a button using VB. Any ideas or a better
way to go about this?
Thanks.

Phil






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default variable inside a formula?

Thanks alot. This looks like it should work fine. I'm new to VB and the Dim
stuff always throws me, but I can follow and understand your example.
Getting ready to head home for the day, so I'll try this later and if I get
stuck I'll post back, but I think I should be able to get it. Thanks.

Don Lloyd wrote:
Phil,
The following macro in a standard module should get you started.

Sub FormulaUpdate()
Dim FileName, Fmla
FileName = Range("A1")
Fmla = "F:\Job Info\PAY APPLICATION\[" & FileName & "]Pay App 1'!L13"
Range("A2") = Fmla
End Sub

Regards,
Don

"Phil" wrote in message
...
This is what I'm trying to do.

I have a formula in a cell A2 that reads as follows:
='F:\Job Info\PAY APPLICATION\[blank.xls]Pay App 1'!L13

Is there a way to have the user type in the real name of the file,
in say another cell or a text box(on a form) that will enter itself
into the above formula where blank.xls is?
So when the user types in File1.xls as the name of the file in cell
A1, the formula in cell A2 adjusts to read:
='F:\Job Info\PAY APPLICATION\[File1.xls]Pay App 1'!L13

Can be a marco or click action on a button using VB. Any ideas or a
better way to go about this?
Thanks.

Phil



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
formulas inside another formula? Christopher[_3_] Excel Worksheet Functions 3 November 2nd 08 06:28 PM
Run a Macro inside a formula crash20001 Excel Discussion (Misc queries) 5 June 12th 08 08:39 PM
Using a range variable inside a excel function Michael Excel Discussion (Misc queries) 2 November 14th 05 02:52 PM
using variable inside activeCell reference call dabith[_7_] Excel Programming 2 June 19th 04 08:02 PM
looping with formula inside a.ekster Excel Programming 1 October 27th 03 03:30 AM


All times are GMT +1. The time now is 10:03 AM.

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

About Us

"It's about Microsoft Excel"