C
ChrisA
To all:
On Sheet 1 of my workbook, I have a date in cell A1. In the next sheet, I
want the same date as the previous sheet plus seven days. When I copy the
latest sheet, I want it to reference the sheet located prior to it rather
than referencing the original sheet (Sheet 1). After copying 52 worksheets,
I want each of them to reference the sheet located just prior to each of the
sheets.
I found this User Defined Function posted here on this discussion site and
it works great except for one thing. If I change the original date on Sheet
1, the UDF does not automatically update. Is there a way that I could make
this happen???
Any help would be greatly appreciated.
ChrisA
Function PrevSheet(rg As Range)
'Enter =PrevSheet(B1) on sheet2 and you'll get B1 from sheet1.
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
On Sheet 1 of my workbook, I have a date in cell A1. In the next sheet, I
want the same date as the previous sheet plus seven days. When I copy the
latest sheet, I want it to reference the sheet located prior to it rather
than referencing the original sheet (Sheet 1). After copying 52 worksheets,
I want each of them to reference the sheet located just prior to each of the
sheets.
I found this User Defined Function posted here on this discussion site and
it works great except for one thing. If I change the original date on Sheet
1, the UDF does not automatically update. Is there a way that I could make
this happen???
Any help would be greatly appreciated.
ChrisA
Function PrevSheet(rg As Range)
'Enter =PrevSheet(B1) on sheet2 and you'll get B1 from sheet1.
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