Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Public Functions

To simplify unit conversions, I created a series of functions like the
following, intended to be used either by typing the function directly in the
cell

=8*LPS2CFM()

or by highlighting the cell(s), and selecting it from a custom menu, which
executes the subroutine below.

The code defining them is in a workbook called Macros.xls, which loads from
the XLStart folder.

They run as expected when tested on the Macros worksheet, but generate a
#Name# error from anywhere else. Can anyone tell me how I can gain access to
them?

Thanks.

Sprinks



Public Function LPS2CFM()
LPS2CFM = 2.118880003
End Function

Public Sub SubLPS2CFM()
Dim Cell As Range
Dim strWS As String
For Each Cell In Selection
If IsNull(Cell.Formula) Or Cell.Formula = "" Then
Else

€˜strip equal sign, rounding, and unnecessary parentheses
strWS = fxnWorkingString(Cell.Formula)

Cell.Formula = "=" & strWS & "*LPS2CFM()"

End If
Next Cell
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Public Functions

You need to put the workbook name in the call to the function:

=8*Macros.xls!LPS2CFM()

If you make your Macros.xls file an add-in, you don't need to
include the workbook name in the function call.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Sprinks" wrote in message
...
To simplify unit conversions, I created a series of functions
like the
following, intended to be used either by typing the function
directly in the
cell

=8*LPS2CFM()

or by highlighting the cell(s), and selecting it from a custom
menu, which
executes the subroutine below.

The code defining them is in a workbook called Macros.xls,
which loads from
the XLStart folder.

They run as expected when tested on the Macros worksheet, but
generate a
#Name# error from anywhere else. Can anyone tell me how I can
gain access to
them?

Thanks.

Sprinks



Public Function LPS2CFM()
LPS2CFM = 2.118880003
End Function

Public Sub SubLPS2CFM()
Dim Cell As Range
Dim strWS As String
For Each Cell In Selection
If IsNull(Cell.Formula) Or Cell.Formula = "" Then
Else

'strip equal sign, rounding, and unnecessary
parentheses
strWS = fxnWorkingString(Cell.Formula)

Cell.Formula = "=" & strWS & "*LPS2CFM()"

End If
Next Cell
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Public Functions

Did you put the VBA code in a general module and NOT a sheet module?

Does that help?

***********
Regards,
Ron

XL2002, WinXP-Pro


"Sprinks" wrote:

To simplify unit conversions, I created a series of functions like the
following, intended to be used either by typing the function directly in the
cell

=8*LPS2CFM()

or by highlighting the cell(s), and selecting it from a custom menu, which
executes the subroutine below.

The code defining them is in a workbook called Macros.xls, which loads from
the XLStart folder.

They run as expected when tested on the Macros worksheet, but generate a
#Name# error from anywhere else. Can anyone tell me how I can gain access to
them?

Thanks.

Sprinks



Public Function LPS2CFM()
LPS2CFM = 2.118880003
End Function

Public Sub SubLPS2CFM()
Dim Cell As Range
Dim strWS As String
For Each Cell In Selection
If IsNull(Cell.Formula) Or Cell.Formula = "" Then
Else

€˜strip equal sign, rounding, and unnecessary parentheses
strWS = fxnWorkingString(Cell.Formula)

Cell.Formula = "=" & strWS & "*LPS2CFM()"

End If
Next Cell
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Public Functions

Hi, Ron.

Ironically, I was just reading about that potential cause in my Walkenbach's
Power Programming book when the email came in, but that's not it--they are
located in Module1.



"Ron Coderre" wrote:

Did you put the VBA code in a general module and NOT a sheet module?

Does that help?

***********
Regards,
Ron

XL2002, WinXP-Pro


"Sprinks" wrote:

To simplify unit conversions, I created a series of functions like the
following, intended to be used either by typing the function directly in the
cell

=8*LPS2CFM()

or by highlighting the cell(s), and selecting it from a custom menu, which
executes the subroutine below.

The code defining them is in a workbook called Macros.xls, which loads from
the XLStart folder.

They run as expected when tested on the Macros worksheet, but generate a
#Name# error from anywhere else. Can anyone tell me how I can gain access to
them?

Thanks.

Sprinks



Public Function LPS2CFM()
LPS2CFM = 2.118880003
End Function

Public Sub SubLPS2CFM()
Dim Cell As Range
Dim strWS As String
For Each Cell In Selection
If IsNull(Cell.Formula) Or Cell.Formula = "" Then
Else

€˜strip equal sign, rounding, and unnecessary parentheses
strWS = fxnWorkingString(Cell.Formula)

Cell.Formula = "=" & strWS & "*LPS2CFM()"

End If
Next Cell
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Public Functions

Chip,

Thank you. I have made the new functions an add-in as you suggest; works
perfectly. I also enjoy the integration into the fx dialog.

Thanks again.

Sprinks

"Chip Pearson" wrote:

You need to put the workbook name in the call to the function:

=8*Macros.xls!LPS2CFM()

If you make your Macros.xls file an add-in, you don't need to
include the workbook name in the function call.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Sprinks" wrote in message
...
To simplify unit conversions, I created a series of functions
like the
following, intended to be used either by typing the function
directly in the
cell

=8*LPS2CFM()

or by highlighting the cell(s), and selecting it from a custom
menu, which
executes the subroutine below.

The code defining them is in a workbook called Macros.xls,
which loads from
the XLStart folder.

They run as expected when tested on the Macros worksheet, but
generate a
#Name# error from anywhere else. Can anyone tell me how I can
gain access to
them?

Thanks.

Sprinks



Public Function LPS2CFM()
LPS2CFM = 2.118880003
End Function

Public Sub SubLPS2CFM()
Dim Cell As Range
Dim strWS As String
For Each Cell In Selection
If IsNull(Cell.Formula) Or Cell.Formula = "" Then
Else

'strip equal sign, rounding, and unnecessary
parentheses
strWS = fxnWorkingString(Cell.Formula)

Cell.Formula = "=" & strWS & "*LPS2CFM()"

End If
Next Cell
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make my functions public to all workbooks? DMB Excel Discussion (Misc queries) 3 February 16th 06 02:20 PM
microsoft.public.excel.worksheet.functions Ian Edmont Excel Discussion (Misc queries) 3 December 14th 05 09:06 AM
Refering to Public Variables in Functions ExcelMonkey Excel Programming 3 October 12th 05 04:45 PM
Where to Place Public Subs and Functions Chaplain Doug Excel Programming 6 May 19th 05 05:32 PM
Public Functions As Worksheet Available Functions Steve King Excel Programming 3 February 12th 05 07:55 PM


All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"