I have the following function set up to dynamically pull a value from the preceding sheet in a file:
Function PrevSheet()
Dim xIndex As Long
Application.Volatile
xIndex = RCell.Worksheet.Index
If xIndex > 1 Then _
PrevSheet = Worksheets(xIndex - 1).Range(RCell.Address)
End Function
My problem is that it works in one file, but when I copy the code to a different file and try to use it, I get the #VALUE! error.
Please help!
Function PrevSheet()
Dim xIndex As Long
Application.Volatile
xIndex = RCell.Worksheet.Index
If xIndex > 1 Then _
PrevSheet = Worksheets(xIndex - 1).Range(RCell.Address)
End Function
My problem is that it works in one file, but when I copy the code to a different file and try to use it, I get the #VALUE! error.
Please help!