ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   variable inside a formula? (https://www.excelbanter.com/excel-programming/305206-variable-inside-formula.html)

Phil

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



Bob Phillips[_6_]

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





Phil

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




Phil

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




Don Lloyd

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





Bob Phillips[_6_]

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







All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com