Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
BKJ BKJ is offline
external usenet poster
 
Posts: 2
Default Assigning a worksheet name to a variable

#Hello, I am trying to structure a worksheet that uses the HLOOKUP function
to show data selected from a worksheet in a different workbook. I have
several different workbooks with several different worksheets, all structured
the same. I would like to be able to define a named cell for the table array
value in the function and then by only changing the contents of the name
cell, redirect the HLOOKUP function to the appropriate worksheet to display
the desired data. But when I substitute the sheet in the formula with the
named cell containing the name of the worksheet in the other workbook, I get
#N/A. How do I assign the name of the sheet (or the named array in the
sheet) to a variable that I can use in the formula?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Assigning a worksheet name to a variable

Use INDIRECT() within your formula

A1 = sheet name

=INDIRECT("'" & A1 & "'!A2")
the above formula will refer cell A2 of sheet mentioned in cell A1.

If this post helps click Yes
---------------
Jacob Skaria


"BKJ" wrote:

#Hello, I am trying to structure a worksheet that uses the HLOOKUP function
to show data selected from a worksheet in a different workbook. I have
several different workbooks with several different worksheets, all structured
the same. I would like to be able to define a named cell for the table array
value in the function and then by only changing the contents of the name
cell, redirect the HLOOKUP function to the appropriate worksheet to display
the desired data. But when I substitute the sheet in the formula with the
named cell containing the name of the worksheet in the other workbook, I get
#N/A. How do I assign the name of the sheet (or the named array in the
sheet) to a variable that I can use in the formula?

  #3   Report Post  
Posted to microsoft.public.excel.programming
BKJ BKJ is offline
external usenet poster
 
Posts: 2
Default Assigning a worksheet name to a variable

I have tried using Indirect, and if I enter the actual data references in the
formula, I receive the correct answer. And when I view the formula in the
function arguments dialog box all of the arguments are shown with the
Table_Array argument displayed as an array. But when I substitute the direct
references for named cells with the text of the references, the displayed
result is #REF and when I view the formula in the function arguments dialog
box, the INDIRECT() function is defined as 'volatile'.

"Jacob Skaria" wrote:

Use INDIRECT() within your formula

A1 = sheet name

=INDIRECT("'" & A1 & "'!A2")
the above formula will refer cell A2 of sheet mentioned in cell A1.

If this post helps click Yes
---------------
Jacob Skaria


"BKJ" wrote:

#Hello, I am trying to structure a worksheet that uses the HLOOKUP function
to show data selected from a worksheet in a different workbook. I have
several different workbooks with several different worksheets, all structured
the same. I would like to be able to define a named cell for the table array
value in the function and then by only changing the contents of the name
cell, redirect the HLOOKUP function to the appropriate worksheet to display
the desired data. But when I substitute the sheet in the formula with the
named cell containing the name of the worksheet in the other workbook, I get
#N/A. How do I assign the name of the sheet (or the named array in the
sheet) to a variable that I can use in the formula?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Assigning a worksheet name to a variable

use the INDIRECT() Function to do this...

if B7 contains teh word Sheet2
in another cell
=INDIRECT(B7 & "!A1")
wil return teh value of range A1 in sheet2



"BKJ" wrote:

#Hello, I am trying to structure a worksheet that uses the HLOOKUP function
to show data selected from a worksheet in a different workbook. I have
several different workbooks with several different worksheets, all structured
the same. I would like to be able to define a named cell for the table array
value in the function and then by only changing the contents of the name
cell, redirect the HLOOKUP function to the appropriate worksheet to display
the desired data. But when I substitute the sheet in the formula with the
named cell containing the name of the worksheet in the other workbook, I get
#N/A. How do I assign the name of the sheet (or the named array in the
sheet) to a variable that I can use in the formula?

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
Assigning a Variable to an Expression that Includes a Variable andVBA Property bluebird[_3_] Excel Programming 3 April 27th 09 07:38 AM
Assigning a variable Zack Excel Worksheet Functions 3 December 11th 08 07:00 PM
Assigning a min to a variable Ed Excel Programming 3 August 3rd 06 06:05 PM
assigning worksheet variable Simon Shaw[_4_] Excel Programming 4 May 29th 04 04:04 AM
Assigning worksheet to worksheet variable PO Excel Programming 3 February 10th 04 02:22 PM


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