Relative reference to sheet cells

N Prakash

Active Member
Joined
Nov 7, 2003
Messages
409
Hi,

I have about 100 sheets and I want to enter a start date in the Fourth sheet in cell B1. If I enter a formulae (eg. =Sheet4!B1+1) in fifth sheet by grouping all other sheets it should have a relative reference to the previous sheet and add one day in the subsequent sheet. Is it possible with formulae.

Any help please.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You can to use

Code:
Sub formulaLoadI()

For Each SH In ThisWorkbook.Worksheets
If SH.CodeName <> "Sheet1" Then
SH.Range("B1").Formula = "=Sheet" & (Replace(SH.CodeName, "Sheet", "") - 1) & "!RC+1"
End If

Next SH

End Sub
or

Code:
Sub formulaLoadII()

For Each SH In ThisWorkbook.Worksheets
If SH.Name <> "Sheet1" Then
SH.Range("B1").Formula = "=Sheet" & (Replace(SH.Name, "Sheet", "") - 1) & "!RC+1"
End If

Next SH

End Sub

Galileogali
 
Upvote 0
Hi,

You could use a user defined function
Code:
Function prevsheetvalue()
    With Application.Caller
    prevsheetvalue = .Parent.Previous.Range(.Address).Value + 1
    End With
End Function

example:
sheet1 A3: "123"
sheet2 A3: = prevsheetvalue()
result "124"

kind regards,
Erik

EDIT:
some errorhandling in case you use this on first sheet (which would produce an error)
Code:
Function prevsheetvalue()

    With Application.Caller
        If .Parent.Index = 1 Then
        prevsheetvalue = "error"
        Else
        prevsheetvalue = .Parent.Previous.Range(.Address).Value + 1
        End If
    End With

End Function
 
Upvote 0
Hi,

Thank you very much for all the help. User defined function prevsheetvalue() is great.

Regards,
Prakash
 
Upvote 0

Forum statistics

Threads
1,217,681
Messages
6,137,953
Members
450,100
Latest member
mscetr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top