Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Accessing sheets based on cell contents

I want to create a formula with variable sheet names based on the contents of
a cell.

A1 = Sheet1
A2 = Sheet2
B1 = yes
B2 = No

=IF(B1='yes','A1'!X1)+IF(B2='yes','A2'!X1)
Where A1 and A2 resolve for the contents of A1 and A2 resulting in:
=IF(B1='yes','Sheet1'!X1)+IF(B2='yes','Sheet2'!X1)

Any help would be greatly appreciated.
Mike


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 65
Default Accessing sheets based on cell contents

Try something like this:

=IF(B1="yes",INDIRECT("'"&$A1&"'!X1")+IF(B2="yes", INDIRECT("'"&$A2&"'!X1")))

"Mike" wrote in message
...
I want to create a formula with variable sheet names based on the contents
of
a cell.

A1 = Sheet1
A2 = Sheet2
B1 = yes
B2 = No

=IF(B1='yes','A1'!X1)+IF(B2='yes','A2'!X1)
Where A1 and A2 resolve for the contents of A1 and A2 resulting in:
=IF(B1='yes','Sheet1'!X1)+IF(B2='yes','Sheet2'!X1)

Any help would be greatly appreciated.
Mike




  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Accessing sheets based on cell contents

Use INDIRECT to resolve the variable sheetnames* in A1:A2 ..

Place this in say, C1:
=IF(AND(B1="yes",B2="yes"),SUM(INDIRECT("'"&A1&"'! X1"),INDIRECT("'"&A2&"'!X1")),"")

The expression will return "nothing", ie:"", as the value_if_false (you
didn't specify this in your post). Note that we have to use double quotes for
text:"yes" (not 'yes').

*Ensure there's 100% consistency between the actual sheetnames and the names
entered within A1:A2 (check for possible typos, extra white spaces, etc if
you get #REF!)
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Mike" wrote:
I want to create a formula with variable sheet names based on the contents of
a cell.

A1 = Sheet1
A2 = Sheet2
B1 = yes
B2 = No

=IF(B1='yes','A1'!X1)+IF(B2='yes','A2'!X1)
Where A1 and A2 resolve for the contents of A1 and A2 resulting in:
=IF(B1='yes','Sheet1'!X1)+IF(B2='yes','Sheet2'!X1)

Any help would be greatly appreciated.
Mike


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Accessing sheets based on cell contents

Clarification:
*Ensure there's 100% consistency between the actual sheetnames
and the names entered within A1:A2 ..


Except for case, that is (ie it's not case sensitive)
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
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
How do I conditionally delete rows based on cell contents? John Chan Excel Worksheet Functions 3 May 17th 23 03:45 AM
Finding cell contents based on certain criteria thekovinc Excel Discussion (Misc queries) 1 March 15th 06 07:37 PM
Finding cell contents based on certain criteria thekovinc Excel Discussion (Misc queries) 1 March 15th 06 07:20 PM
Conditional Format based on contents of cell. dave m Excel Worksheet Functions 13 April 29th 05 01:12 PM
Formula to return cell contents based on multiple conditions Bill Excel Worksheet Functions 3 January 19th 05 09:59 AM


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