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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

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