Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Jim Jim is offline
external usenet poster
 
Posts: 615
Default need formula to reference a cell in previous worksheet

How can I write a formula to reference a specific cell in a worksheet
immediately preceeding (or immediately after) the worksheet I'm in?

For instance:
If I'm in a worksheet called Week 11 I want my formula to reference a cell
in a worksheet called Week 10. Now I write the formula like this: =H29+'Week
10'!H31. However, I have a bunch of these formulas and a bunch of these
worksheets. Every week I'm in a new sheet, but I always have to look at cell
H31 from the prior week. For now when I generate a new worksheet I copy an
existing one then manually change each formula with the new sheet reference.
Tedious. I'd like to get away from that.

Is there a way for the formula to look something like this: =H29+'Previous
Worksheet'!H31 ?? That way I won't have to manually change it.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default need formula to reference a cell in previous worksheet

Yep:
http://j-walk.com/ss/excel/tips/tip63.htm

If you're new to VBA:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
http://www.mvps.org/dmcritchie/excel/install.htm


"Jim" wrote:

How can I write a formula to reference a specific cell in a worksheet
immediately preceeding (or immediately after) the worksheet I'm in?

For instance:
If I'm in a worksheet called Week 11 I want my formula to reference a cell
in a worksheet called Week 10. Now I write the formula like this: =H29+'Week
10'!H31. However, I have a bunch of these formulas and a bunch of these
worksheets. Every week I'm in a new sheet, but I always have to look at cell
H31 from the prior week. For now when I generate a new worksheet I copy an
existing one then manually change each formula with the new sheet reference.
Tedious. I'd like to get away from that.

Is there a way for the formula to look something like this: =H29+'Previous
Worksheet'!H31 ?? That way I won't have to manually change it.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default need formula to reference a cell in previous worksheet

1) This formula returns to name of the worksheet that hold the formula
=MID(CELL("Filename",A1),FIND("]",CELL("Filename",A1))+1,255)
I seem to recall (it is too late to experiment) the file must be saved first
for it to work
Suppose I have that in D8 of the worksheet named Work2
2) The formula="Work"&MID(D8,5,2)-1&"!H3" in D9 returns the text entry
Work1!H31
Note we do not need single quotes around the worksheet name since the name
has no spaces in it.
3)The formula =INDIRECT(D9) returns the value from the cell H31 in the
previous sheet
I leave it to use to combine this to a single formula if you so require
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Jim" wrote in message
...
How can I write a formula to reference a specific cell in a worksheet
immediately preceeding (or immediately after) the worksheet I'm in?

For instance:
If I'm in a worksheet called Week 11 I want my formula to reference a cell
in a worksheet called Week 10. Now I write the formula like this:
=H29+'Week
10'!H31. However, I have a bunch of these formulas and a bunch of these
worksheets. Every week I'm in a new sheet, but I always have to look at
cell
H31 from the prior week. For now when I generate a new worksheet I copy an
existing one then manually change each formula with the new sheet
reference.
Tedious. I'd like to get away from that.

Is there a way for the formula to look something like this: =H29+'Previous
Worksheet'!H31 ?? That way I won't have to manually change it.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default need formula to reference a cell in previous worksheet

Jim

If you're willing to use a User Defined Function.......


Function PrevSheet(rg As Range)
n = Application.Caller.Parent.Index
If n = 1 Then
PrevSheet = CVErr(xlErrRef)
ElseIf TypeName(Sheets(n - 1)) = "Chart" Then
PrevSheet = CVErr(xlErrNA)
Else
PrevSheet = Sheets(n - 1).Range(rg.Address).Value
End If
End Function

Say you have 20 sheets, sheet1 through sheet20...........sheet names don't
matter.

Select second sheet and SHIFT + Click last sheet

In B1 enter =PrevSheet(A1)

Ungroup the sheets.

Each B1 will have the contents of the previous sheet's A1

Copy/paste the UDF above into a General Module in your workbook.

If not familiar with macros and VBA, visit David McRitchie's website on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the above code in there. Save the
workbook and hit ALT + Q to return to your workbook.


Gord Dibben Excel MVP


On Thu, 4 Jan 2007 17:00:00 -0800, Jim wrote:

How can I write a formula to reference a specific cell in a worksheet
immediately preceeding (or immediately after) the worksheet I'm in?

For instance:
If I'm in a worksheet called Week 11 I want my formula to reference a cell
in a worksheet called Week 10. Now I write the formula like this: =H29+'Week
10'!H31. However, I have a bunch of these formulas and a bunch of these
worksheets. Every week I'm in a new sheet, but I always have to look at cell
H31 from the prior week. For now when I generate a new worksheet I copy an
existing one then manually change each formula with the new sheet reference.
Tedious. I'd like to get away from that.

Is there a way for the formula to look something like this: =H29+'Previous
Worksheet'!H31 ?? That way I won't have to manually change it.


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
Cell reference in different worksheet in formula Robb Excel Worksheet Functions 1 May 30th 06 06:52 PM
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
Worksheet name / reference as a formula? gabriel_e Excel Discussion (Misc queries) 4 January 24th 06 12:23 PM
Copy worksheet & maintain cell reference across worksheets dingy101 Excel Worksheet Functions 3 January 2nd 06 10:51 AM
name of another worksheet in cell for reference Tom A Johnson Excel Worksheet Functions 2 November 11th 04 11:28 PM


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