VBA - changing VOLATILITY of a UDF called PrevSheet(), which references Previous Tab

thegurumonkey

New Member
Joined
Sep 18, 2015
Messages
13
Hi,


I'm hoping to use the UDF PrevSheet() to replace INDIRECT() for referencing data in previous sheets, TO AVOID IT BEING VOLATILE
BUT the code for the macro says this is volatile too.


Can I simple replace the line:


Application.Volatile True
with
Application.Volatile False

By which i mean, would that work, rather than would that be wise (though I'm interested in both answers)


For reference, the entire code was:


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




Also, a separate but related quick question:


I need a NextSheet() too, so can I basically change both occurences of the name itself and change one '-' to a '+':
i.e.
PrevSheet = Sheets(i - 1).Range(rCell.Address)
to
NextSheet = Sheets(i + 1).Range(rCell.Address)


Sorry if it's more complicated than that. I'm just guessing and have zero experience with VBA.

HUGE HUGE thanks in advance! VERY useful!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,226,116
Messages
6,189,057
Members
453,523
Latest member
Don Quixote

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