UDF reference previous page error when open new workbook

ALMack

New Member
Joined
Aug 13, 2009
Messages
1
Greetings,

I used a "user defined function" to reference a cell on the previous worksheet regardless of the worksheet's name.
The function works fine and updates automatically until I open a new workbook; at which point the original worksheet (with the UDF) reads the cells from the newly opened worksheet. I can correct it by pressing F9, but I don't want to manually correct each time.
I looked through the Mr.Excel database but I could not find a reference to this problem.

Here is the UDF:

Function Prev_sheet(rcell As Range)
Application.Volatile True
Dim i As Integer
i = rcell.Cells(1).Parent.Index
Prev_sheet = Sheets(i - 1).Range(rcell.Address)
End Function

I'm new at this, so is there a way to write the function to be workbook specific?

Thanks - Andrew.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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