Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Copying worksheets?

Is it possible to automatically change a specific formula which references
the previous worksheet? example:
Day 1 is subtracted from the Day 2 total, when I copy the sheet to name it
Day 3, I want the formula to subtract Day 2 from Day 3. I have to make 31
copies for each day of the month. Is there an easier way to make the change
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,722
Default Copying worksheets?

The first task is to create a formula that can detect the number of the day
of your sheet.
=RIGHT(CELL("filename",A1),1)
and the corresponding sheet to subtract will then be
=RIGHT(CELL("filename",A1),1)-1

To use this information in a formula, we can use the INDIRECT function,
which combines text and formulas to create references. Assuming you are
dealing with cell A2 in each respective worksheet:

=A2-INDIRECT("'Day "&RIGHT(CELL("filename",A1),1)-1&"'!A2")

Placing this formula in sheet Day 3 would create a formula equivalent to:
='Day 3'!A2 - 'Day 2'!A2

Notes:
Do NOT change "filename" to your actual file name. This is part of the
formula structure.
Pay close attention to the placement of double and single quotes within the
INDIRECT function.
Within the CELL function, it does not matter what cell you reference.

--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"KellyLC" wrote:

Is it possible to automatically change a specific formula which references
the previous worksheet? example:
Day 1 is subtracted from the Day 2 total, when I copy the sheet to name it
Day 3, I want the formula to subtract Day 2 from Day 3. I have to make 31
copies for each day of the month. Is there an easier way to make the change

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Copying worksheets?

Copy/paste this UDF to a general module in your worksheet.

Function PrevSheet(rg As Range)
'accounts for more than one workbook open
'and has hidden sheets
'Bob Phillips October 4, 2009
Dim N As Variant
With Application.Caller.Parent
N = .Index
Do
If N = 1 Then
PrevSheet = CVErr(xlErrRef)
Exit Do
ElseIf TypeName(.Parent.Sheets(N - 1)) < "Chart" And _
.Parent.Sheets(N - 1).Visible = xlSheetVisible Then
PrevSheet = .Parent.Sheets(N - 1).Range(rg.Address).Value
Exit Do
End If
N = N - 1
Loop
End With
End Function

In Sheet2 enter =prevsheet(A1) which refers to Sheet1 .

When you copy Sheet2 to name it Sheet3 then Sheet2 will become the "previous
sheet"


Gord Dibben MS Excel MVP

On Mon, 5 Oct 2009 10:28:37 -0700, KellyLC
wrote:

Is it possible to automatically change a specific formula which references
the previous worksheet? example:
Day 1 is subtracted from the Day 2 total, when I copy the sheet to name it
Day 3, I want the formula to subtract Day 2 from Day 3. I have to make 31
copies for each day of the month. Is there an easier way to make the change


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
Copying worksheets tiger21 Excel Discussion (Misc queries) 1 December 28th 07 07:55 PM
Copying worksheets Mick Excel Worksheet Functions 5 February 25th 07 11:33 PM
Copying Worksheets Rich Excel Worksheet Functions 0 January 18th 07 05:00 PM
copying worksheets Nadji New Users to Excel 2 October 4th 06 08:41 PM
Copying Worksheets TamW Excel Discussion (Misc queries) 1 October 4th 05 04:12 PM


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