masterkemist
New Member
- Joined
- Feb 1, 2005
- Messages
- 11
Hello.
I have been pulling my hair out trying to get this to work. I only have two hairs left and they're fighting with eachother. I want to call a udf to reference the sheet before my active sheet. Their are twelve sheets (one for each month). Here is what I want to accomplish and the code I am using in VB.
I want to do this with relative sheet referencing:
=IF(Jan!G9=Feb!L9,IF(Jan!$H9="","",Jan!$H9),"")
as well as this:
=IF($K9>0,Jan!G9,"")
So, I searched, learned, and searched some more. I tried this:
=IF($K9>0,PrevSheetName()&"!G9","")
...and the code...
code:
--------------------------------------------------------------------------------
'this will return the name of the previous sheet'
Function PrevSheetName() As String
Application.Volitile True
With Application.Caller.Parent
If .Index = 1 Then
PrevSheetName = .Parent.Worksheets(.Parent.Worksheets.Count).Name
Else
PrevSheetName = .Previous.Name
End If
End With
End Function
--------------------------------------------------------------------------------
I cannot seem to get aroung the #NAME? error that keeps occuring. VERY FRUSTRATING.
Any help would be greatly appreciated. I am running Windows XP with Excel 2002.
I have been pulling my hair out trying to get this to work. I only have two hairs left and they're fighting with eachother. I want to call a udf to reference the sheet before my active sheet. Their are twelve sheets (one for each month). Here is what I want to accomplish and the code I am using in VB.
I want to do this with relative sheet referencing:
=IF(Jan!G9=Feb!L9,IF(Jan!$H9="","",Jan!$H9),"")
as well as this:
=IF($K9>0,Jan!G9,"")
So, I searched, learned, and searched some more. I tried this:
=IF($K9>0,PrevSheetName()&"!G9","")
...and the code...
code:
--------------------------------------------------------------------------------
'this will return the name of the previous sheet'
Function PrevSheetName() As String
Application.Volitile True
With Application.Caller.Parent
If .Index = 1 Then
PrevSheetName = .Parent.Worksheets(.Parent.Worksheets.Count).Name
Else
PrevSheetName = .Previous.Name
End If
End With
End Function
--------------------------------------------------------------------------------
I cannot seem to get aroung the #NAME? error that keeps occuring. VERY FRUSTRATING.