• flickr
  • linkedin
  • twitter
  • rss
Value from previous sheet in Excel

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:

Larry's a 30-something chap interested in travel, being a dork and changing the world via less boring training.

Leave a reply