UDF If based on UDF

BarefootPaul

Board Regular
Joined
Jul 21, 2011
Messages
54
I am trying to create a UDF based on this UDF that I found on the internet somewhere:

Code:
Function RefOnPrevSheet(Addr As String) As Variant
    Application.Volatile True
    With Application.Caller.Parent
    If .Index = 1 Then
        RefOnPrevSheet = _
        .Parent.Worksheets(.Parent.Worksheets.Count).Range(Addr).Value
    Else
        RefOnPrevSheet = .Previous.Range(Addr).Value
    End If
    End With
End Function

I have been typing out:
=If(0=RefOnPrevSheet("A1"),"", RefOnPrevSheet("A1"))

I tried writing it as:

Code:
Function IfPrevBlank(Addr As String) As Variant
    IfPrevBlank = Application.If(0=RefOnPrevSheet(Addr), "", RefOnPrevSheet(Addr))
End Function

but I get a circular reference error.

Any help is greatly appreciated.
 

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