stevenkimbell
New Member
- Joined
- Aug 6, 2017
- Messages
- 2
I inserted a Prevsheet function into VB and saved it to my personal workbook. I wanted it available to all workbooks later. Initially it would not run in any workbook - i had to try several different versions until one finally worked in budget spredsheet. I use it to carry totals over from one week to the next, adding them to the current week's totals. However, I have some extreme difficulty getting it to work in other workbooks. Moreover, when I select Developer - Macros, it never shows up, even in the budget workbook where it functions. I select the current workbook, the personal, all open workbooks - nowhere do I see it.
I am now creating a new workbook using data from one month to another and need the function. I persistently get an error of #Name ?. I tried opening VB while actively in this workbook and copying the Prevsheet module into it - NoGo. I tried creating it as a new entry - again NoGo. I tried using two alternate versions, Same Old, Same Old.
I am stumped.
I have looked at Options - Trust Center to ensure macros aren't disabled. I even tried copying a sheet from the functioning workbook - my budget - into the new workbook. Suggestions?
Below is the current macro in use, the one that works in the budget.
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
I also tried a simpler version that seems to work for some people:
Function PrevSheet(rng As Range)
Application.Volatile
PrevSheet = rng.Parent.previous.Range(rg.Address)
End Function
I am now creating a new workbook using data from one month to another and need the function. I persistently get an error of #Name ?. I tried opening VB while actively in this workbook and copying the Prevsheet module into it - NoGo. I tried creating it as a new entry - again NoGo. I tried using two alternate versions, Same Old, Same Old.
I am stumped.
I have looked at Options - Trust Center to ensure macros aren't disabled. I even tried copying a sheet from the functioning workbook - my budget - into the new workbook. Suggestions?
Below is the current macro in use, the one that works in the budget.
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
I also tried a simpler version that seems to work for some people:
Function PrevSheet(rng As Range)
Application.Volatile
PrevSheet = rng.Parent.previous.Range(rg.Address)
End Function