Value from previous sheet in Excel

I changed this to not give an error if it finds nothing, but to produce 0. Used for accumulating overtime, so very important you see.

Function PrevSheet(Range As Range)
Application.Volatile
PrevSheet = Application.Caller.Parent.Index

If PrevSheet = 1 Then
PrevSheet = 0
ElseIf Sheets(PrevSheet - 1).Type <> -4167 Then
PrevSheet = CVErr(xlErrNA)
Else
PrevSheet = Sheets(PrevSheet - 1) _
.Range(Range.Address).Value
End If
End Function

Big thanks to
http://www.methodsinexcel.co.uk/Articles/one%20before.html

Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑