Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
malik641
 
Posts: n/a
Default Using Name as Worksheet Reference


I have a defined name that holds the names of each relevant worksheet I
want to calculate.

Lets Say I want to sum every A1 in each worksheet in the defined name.
How would I go about doing that?


--
malik641


------------------------------------------------------------------------
malik641's Profile: http://www.excelforum.com/member.php...o&userid=24190
View this thread: http://www.excelforum.com/showthread...hreadid=401807

  #2   Report Post  
Bruno Campanini
 
Posts: n/a
Default

"malik641" wrote in
message ...

I have a defined name that holds the names of each relevant worksheet I
want to calculate.


Do you mean a Collection of worksheets you want to calculate?

-------------------------------------
Dim i, SumOfA1Cells as Currency
For Each i In NameOfSheets
SumOfA1Cells = SumOfA1Cells + Val(Sheets(i).[a1])
Next
-------------------------------------

Lets Say I want to sum every A1 in each worksheet in the defined name.
How would I go about doing that?


Or, for any worksheet in active workbook:
--------------------------------------------
Dim i, SumOfA1Cells As Currency
For Each i In ThisWorkbook.Worksheets
SumOfA1Cells = SumOfA1Cells + Sheets(i.Name).[a1]
Next
--------------------------------------------

Bruno


  #3   Report Post  
Bruno Campanini
 
Posts: n/a
Default

"Bruno Campanini" wrote in message
...

Ooops!

That's better:

For Each i In NameOfSheets
SumOfA1Cells = SumOfA1Cells + Val(Sheets(i.Name).[a1])
Next

Bruno


  #4   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Try this:

J1 = Sheet1
J2 = Sheet3
J3 = Sheet10

J1:J3 is given the defined name SheetNames

=SUMPRODUCT(N(INDIRECT("'"&SheetNames&"'!A1")))

This will SUM Sheet1!A1, Sheet3!A1, Sheet10!A1

Biff

"malik641" wrote in
message ...

I have a defined name that holds the names of each relevant worksheet I
want to calculate.

Lets Say I want to sum every A1 in each worksheet in the defined name.
How would I go about doing that?


--
malik641


------------------------------------------------------------------------
malik641's Profile:
http://www.excelforum.com/member.php...o&userid=24190
View this thread: http://www.excelforum.com/showthread...hreadid=401807



  #5   Report Post  
malik641
 
Posts: n/a
Default


Biff Wrote:
Hi!

Try this:

J1 = Sheet1
J2 = Sheet3
J3 = Sheet10

J1:J3 is given the defined name SheetNames

=SUMPRODUCT(N(INDIRECT("'"&SheetNames&"'!A1")))

This will SUM Sheet1!A1, Sheet3!A1, Sheet10!A1

Biff

I'm getting a #Name? error with this. I checked it out and the error
comes from this:

""&SheetNames&"

I have NO clue how this worksheet function is supposed to work.
Especially the N before the INDIRECT function. Can you explain that a
little bit??

Thanks


--
malik641


------------------------------------------------------------------------
malik641's Profile: http://www.excelforum.com/member.php...o&userid=24190
View this thread: http://www.excelforum.com/showthread...hreadid=401807



  #6   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

You need to give the range a name (insertnamedefine) as per your
instructions

"J1:J3 is given the defined name SheetNames"

or use the range as in

=SUMPRODUCT(N(INDIRECT("'"&J1:J3&"'!A1")))


--
Regards,

Peo Sjoblom

(No private emails please)


"malik641" wrote in
message ...

Biff Wrote:
Hi!

Try this:

J1 = Sheet1
J2 = Sheet3
J3 = Sheet10

J1:J3 is given the defined name SheetNames

=SUMPRODUCT(N(INDIRECT("'"&SheetNames&"'!A1")))

This will SUM Sheet1!A1, Sheet3!A1, Sheet10!A1

Biff

I'm getting a #Name? error with this. I checked it out and the error
comes from this:

""&SheetNames&"

I have NO clue how this worksheet function is supposed to work.
Especially the N before the INDIRECT function. Can you explain that a
little bit??

Thanks


--
malik641


------------------------------------------------------------------------
malik641's Profile:
http://www.excelforum.com/member.php...o&userid=24190
View this thread: http://www.excelforum.com/showthread...hreadid=401807


  #7   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Peo explained the #NAME? problem.

As far as N goes.......

I don't know the exact reason it's needed. It's one of those quirky type
things you just run into.

It usually comes into play when you're trying to deal with 3D references.
For some reason if you just used:

=SUMPRODUCT(INDIRECT("'"&SheetNames&"'!A1"))

The arguments to INDIRECT will return #VALUE! errors. Using N (in this case)
causes the arguments to actually return their true values. The N() function
is used for numeric values and the T() function is used for text values.

If you only wanted to sum the same cell on 3 different sheets I would just
use:

=SUM(Sheet1!A1,Sheet3!A1,Sheet10!A1)

The SUMPRODUCT method is good if you have many sheets to sum.

Biff

"malik641" wrote in
message ...

Biff Wrote:
Hi!

Try this:

J1 = Sheet1
J2 = Sheet3
J3 = Sheet10

J1:J3 is given the defined name SheetNames

=SUMPRODUCT(N(INDIRECT("'"&SheetNames&"'!A1")))

This will SUM Sheet1!A1, Sheet3!A1, Sheet10!A1

Biff

I'm getting a #Name? error with this. I checked it out and the error
comes from this:

""&SheetNames&"

I have NO clue how this worksheet function is supposed to work.
Especially the N before the INDIRECT function. Can you explain that a
little bit??

Thanks


--
malik641


------------------------------------------------------------------------
malik641's Profile:
http://www.excelforum.com/member.php...o&userid=24190
View this thread: http://www.excelforum.com/showthread...hreadid=401807



  #8   Report Post  
Harlan Grove
 
Posts: n/a
Default

"Biff" wrote...
....
As far as N goes.......

I don't know the exact reason it's needed. It's one of those
quirky type things you just run into.

It usually comes into play when you're trying to deal with
3D references.

....

It's not 3D referencing. Calling INDIRECT or OFFSET with array arguments
results in those functions returning something that behaves like an array of
range references. There are very few other functions that can cope with such
beasts, certainly not SUMPRODUCT. N and T functions convert these into
arrays of numbers or strings, which SUMPRODUCT can handle.


  #9   Report Post  
malik641
 
Posts: n/a
Default


Awesome, got it!

Now I need to figure out how to use this with certain criteria...hmmmm




But anyway thanks again Biff and Peo.
Bruno, thanks for the VBA but I kinda wanted to avoid using a VBA
Function. Guess I should have specified. Sorry


--
malik641


------------------------------------------------------------------------
malik641's Profile: http://www.excelforum.com/member.php...o&userid=24190
View this thread: http://www.excelforum.com/showthread...hreadid=401807

  #10   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Now I need to figure out how to use this with certain criteria


Depends on what you want to do.

You might be able to use something like:

=SUMPRODUCT(SUMIF(................................ ..

Biff

"malik641" wrote in
message ...

Awesome, got it!

Now I need to figure out how to use this with certain criteria...hmmmm




But anyway thanks again Biff and Peo.
Bruno, thanks for the VBA but I kinda wanted to avoid using a VBA
Function. Guess I should have specified. Sorry


--
malik641


------------------------------------------------------------------------
malik641's Profile:
http://www.excelforum.com/member.php...o&userid=24190
View this thread: http://www.excelforum.com/showthread...hreadid=401807





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
Worksheet reference behaving funny Dennis Excel Discussion (Misc queries) 2 July 10th 05 12:30 PM
Cell Reference Math Ralph Howarth Excel Worksheet Functions 0 January 26th 05 06:27 PM
Worksheet reference (i.e placing worksheet name in a cell) Roger Roger Excel Worksheet Functions 1 January 20th 05 03:40 PM
Indirect reference from one worksheet to another Bill Sturdevant Excel Worksheet Functions 2 December 17th 04 01:23 PM
Reference a cell to get worksheet name Fysh Excel Worksheet Functions 2 December 15th 04 08:57 PM


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