UDF How to record in Excel

J

John Baker

Hi:
Someone has given me a UDF which is coded as follows::

Private Function WorkbookIsOpen(wbname) As Boolean
' Returns TRUE if the workbook is open
Dim x As Workbook
On Error Resume Next
Set x = Workbooks(wbname)
If Err = 0 Then WorkbookIsOpen = True _
Else WorkbookIsOpen = False
End Function


I want to implement this so that it can be called for a sp[eciofic workbook. I have
presently tucked it in the same area as the macros, but when I call it I get a errpr "Sub
of Funcvtion undefined". The call is corrfect, but somehow the function isn't being
excited.

Can some one give me a step by step outline of how I record a functions such as this?

Thanks

John Baker
 
D

Dave Peterson

Did you put it in a general module?

Are you calling that function from a sub in a different module?

If yes, remove the word Private from the Function definition statement.

Function WorkbookIsOpen(wbname) As Boolean

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

John said:
Hi:
Someone has given me a UDF which is coded as follows::

Private Function WorkbookIsOpen(wbname) As Boolean
' Returns TRUE if the workbook is open
Dim x As Workbook
On Error Resume Next
Set x = Workbooks(wbname)
If Err = 0 Then WorkbookIsOpen = True _
Else WorkbookIsOpen = False
End Function

I want to implement this so that it can be called for a sp[eciofic workbook. I have
presently tucked it in the same area as the macros, but when I call it I get a errpr "Sub
of Funcvtion undefined". The call is corrfect, but somehow the function isn't being
excited.

Can some one give me a step by step outline of how I record a functions such as this?

Thanks

John Baker
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top