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

Hello,

I would like to set a formala in a cell that would vary based on the value
of an another cell.
The end result should look like: ='040208'!A1+C4 with 040208 being the value
of the cell in question.

How can I do that?

Thank you.

Eric


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Variable within a formula

Put 040208 in A1 and then:
=INDIRECT(A1 & "!C4")
will give you the same as putting:
='040208'!C4
in the same cell


--
Gary''s Student - gsnu2007g


"Eric" wrote:

Hello,

I would like to set a formala in a cell that would vary based on the value
of an another cell.
The end result should look like: ='040208'!A1+C4 with 040208 being the value
of the cell in question.

How can I do that?

Thank you.

Eric



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Variable within a formula

Gary, almost there... I was looking for ='040208'!A1+C4 and not just
'040208'!A1
I tried =INDIRECT(A1 & "!A1+C4") but it didn't work (A1 containing the
value '040208').

Thank you.

Eric

"Gary''s Student" wrote in message
...
Put 040208 in A1 and then:
=INDIRECT(A1 & "!C4")
will give you the same as putting:
='040208'!C4
in the same cell


--
Gary''s Student - gsnu2007g


"Eric" wrote:

Hello,

I would like to set a formala in a cell that would vary based on the

value
of an another cell.
The end result should look like: ='040208'!A1+C4 with 040208 being the

value
of the cell in question.

How can I do that?

Thank you.

Eric





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 221
Default Variable within a formula

G'day Eric

I tried this

=IF(A1="040208",(A1 & "!A1+C4"),0)

It returned

040208!A1+C4


I had to change A1 to a Text for it to work though, as I got a Ref# error
when it was General

HTH
Mark.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Variable within a formula

Hi Mark,

I am trying to end up with the formula =040208!A1+C4 not just with the
string 040208!A1+C4 hence the use of INDIRECT.

Thank you

Eric



"NoodNutt" wrote in message
...
G'day Eric

I tried this

=IF(A1="040208",(A1 & "!A1+C4"),0)

It returned

040208!A1+C4


I had to change A1 to a Text for it to work though, as I got a Ref# error
when it was General

HTH
Mark.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Variable within a formula

Maybe:
=INDIRECT("'" & A1 & "'!A1+C4")
or
=INDIRECT("'" & text(A1,"000000") & "'!A1+C4")
or
=INDIRECT("'" & text(A1,"mmddyy") & "'!A1+C4")

The apostrophes are required for lots of worksheet names.

And depending on what's in A1 (a number formatted to show leading 0's) or a date
formatted nicely), you may need to do that in your formula, too.

Eric wrote:

Gary, almost there... I was looking for ='040208'!A1+C4 and not just
'040208'!A1
I tried =INDIRECT(A1 & "!A1+C4") but it didn't work (A1 containing the
value '040208').

Thank you.

Eric

"Gary''s Student" wrote in message
...
Put 040208 in A1 and then:
=INDIRECT(A1 & "!C4")
will give you the same as putting:
='040208'!C4
in the same cell


--
Gary''s Student - gsnu2007g


"Eric" wrote:

Hello,

I would like to set a formala in a cell that would vary based on the

value
of an another cell.
The end result should look like: ='040208'!A1+C4 with 040208 being the

value
of the cell in question.

How can I do that?

Thank you.

Eric




--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Variable within a formula

Nope, thank you for trying. A1 was already formatted as text and it still
does not work.

All your solutions return the same #REF! as mine.

Thank you.

Eric


"Dave Peterson" wrote in message
...
Maybe:
=INDIRECT("'" & A1 & "'!A1+C4")
or
=INDIRECT("'" & text(A1,"000000") & "'!A1+C4")
or
=INDIRECT("'" & text(A1,"mmddyy") & "'!A1+C4")

The apostrophes are required for lots of worksheet names.

And depending on what's in A1 (a number formatted to show leading 0's) or

a date
formatted nicely), you may need to do that in your formula, too.

Eric wrote:

Gary, almost there... I was looking for ='040208'!A1+C4 and not just
'040208'!A1
I tried =INDIRECT(A1 & "!A1+C4") but it didn't work (A1 containing the
value '040208').

Thank you.

Eric

"Gary''s Student" wrote in

message
...
Put 040208 in A1 and then:
=INDIRECT(A1 & "!C4")
will give you the same as putting:
='040208'!C4
in the same cell


--
Gary''s Student - gsnu2007g


"Eric" wrote:

Hello,

I would like to set a formala in a cell that would vary based on the

value
of an another cell.
The end result should look like: ='040208'!A1+C4 with 040208 being

the
value
of the cell in question.

How can I do that?

Thank you.

Eric




--

Dave Peterson



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Variable within a formula

What formula did you use?

My real bet is that you don't have a worksheet by that name. Maybe there's
something wrong with the value in the cell--or maybe there's something different
with the worksheet tab.

I'd look for leading/trailing spaces in both spots to start.

Eric wrote:

Nope, thank you for trying. A1 was already formatted as text and it still
does not work.

All your solutions return the same #REF! as mine.

Thank you.

Eric

"Dave Peterson" wrote in message
...
Maybe:
=INDIRECT("'" & A1 & "'!A1+C4")
or
=INDIRECT("'" & text(A1,"000000") & "'!A1+C4")
or
=INDIRECT("'" & text(A1,"mmddyy") & "'!A1+C4")

The apostrophes are required for lots of worksheet names.

And depending on what's in A1 (a number formatted to show leading 0's) or

a date
formatted nicely), you may need to do that in your formula, too.

Eric wrote:

Gary, almost there... I was looking for ='040208'!A1+C4 and not just
'040208'!A1
I tried =INDIRECT(A1 & "!A1+C4") but it didn't work (A1 containing the
value '040208').

Thank you.

Eric

"Gary''s Student" wrote in

message
...
Put 040208 in A1 and then:
=INDIRECT(A1 & "!C4")
will give you the same as putting:
='040208'!C4
in the same cell


--
Gary''s Student - gsnu2007g


"Eric" wrote:

Hello,

I would like to set a formala in a cell that would vary based on the
value
of an another cell.
The end result should look like: ='040208'!A1+C4 with 040208 being

the
value
of the cell in question.

How can I do that?

Thank you.

Eric




--

Dave Peterson


--

Dave Peterson
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
formula containing a formula-dependent variable - how? CompeterN New Users to Excel 1 November 8th 06 02:02 PM
Using a variable in a formula Patrick Simonds Excel Programming 7 October 17th 05 09:02 AM
Help With a Variable Formula jdurrmsu Excel Programming 1 September 16th 05 04:22 PM
use a variable in a formula Marcotte A Excel Programming 2 August 26th 04 01:24 AM
Variable in a formula GM[_2_] Excel Programming 6 March 3rd 04 06:27 PM


All times are GMT +1. The time now is 04:30 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"