Forum Discussion

NonYabidnes's avatar
NonYabidnes
Copper Contributor
Oct 29, 2019

PrevSheet in Office 365

I have tried several versions of the PrevSheet function, saving each into my workbook, but all return the same Ambiguous error.  

I am NOT a power user and barely motivate around VBA, looking for answers without all the jargon.  Just need clear instruction on how to make this work.  I have a very large workbook, my budget, that relies on the Prevsheet function.  I used it successfully in every version for years, simply paste into VBA and save.  Office 365 does not seem to like it.  

Most recent version being used:

Function PrevSheet(RCell As Range)
Dim xIndex As Long
Application.Volatile
xIndex = RCell.Worksheet.Index
If xIndex > 1 Then _
PrevSheet = Worksheets(xIndex - 1).Range(RCell.Address)
End Function

 

 

2 Replies

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    NonYabidnes 

     

    I'm on Office365 (on a Mac though). Took your code as it is and copied it into a new VBA module. Works fine. Attaching a workbook with the code and some examples in it. Hope it works on your end as well.

    • NonYabidnes's avatar
      NonYabidnes
      Copper Contributor

      Riny_van_Eekelen 

      The response is much appreciated, but it didn't work.

      I have used this successfully for years, but only in workbooks running under excel on my machine.  For some reason, I cannot get it to work using MSOffice 365.  I get an error "Ambigous Name Detected: Prevsheet when trying to use it with 365.  

       

Resources