Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference next or previous sheet in a formula if the sheet number/name is a varible/variant

How do I reference next or previous sheet in a formula if the sheet number/name is a varible/variant.

I have seen ways to do this with vba, is there a way to do this with a formula or function

like image 625
Dan Avatar asked Sep 03 '25 07:09

Dan


1 Answers

  1. In Excel. Enter an equals sign "=" in any cell. This will put you into interactive mode.

  2. Navigate to your other sheet and click the cell you want to reference. Then hit enter.

  3. Go back to the previous sheet and edit the cell you started in and you should see the formula to use.

To reference the next/prevoius sheet (See example here). You'll need some VB code I think (something along the lines of):

Function PrevSheet(RCell As Range)
    Dim xIndex As Long
    Application.Volatile
    xIndex = RCell.Worksheet.Index
    If xIndex > 1 Then _
        PrevSheet = Worksheets(xIndex - 1).Range(RCell.Address)
End Function

then use

=PrevSheet(A1)
like image 122
Peter Avatar answered Sep 04 '25 23:09

Peter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!