LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Call to custom function appears as typed not as result

I placed the same custom function in a module in 2 workbooks, using
identical code, where it is the only contents of the VBA module. One works
fine, the other does not! Instead of displaying the resulting value I get
the text I typed in to call the function.

My function is AddCC(). The call AddCC("A,B","C") should show the result
"A/C,B/C".
In one workbook this is OK, in the other the cell displays
'AddCC("A,B","C")', with the formula showing as '=AddCC("A,B","C")'

Have I missed an option somewhere. Any other ideas, as I am beat!

CODE
-------
Option Explicit

Option Base 1 ' All arrays to start at 1, not 0

Function AddCC(szAccount As String, szCC As String)

Dim szNewString As String 'Work string to return

Dim i As Integer 'Counter

szAccount = Trim(szAccount)

'Return account + CC if there is only one

If InStr(szAccount, ",") = 0 Then

AddCC = szAccount & "/" & szCC

Exit Function

End If

For i = 1 To Len(szAccount)

If Mid(szAccount, i, 1) < "," Then

'Add next char if not a comma

szNewString = szNewString & Mid(szAccount, i, 1)

Else

'Char is a comma, so add CC

szNewString = szNewString & "/" & szCC & ","

End If

Next

If Right(szAccount, 1) < "," Then

szNewString = szNewString & "/" & szCC

End If

AddCC = szNewString

End Function



 
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
Typed or pasted text in a cell appears as #### susanhasquestion Excel Discussion (Misc queries) 6 September 19th 07 01:50 AM
why cond sum wizard returns diff result as when formula typed out ExcelKat Excel Worksheet Functions 4 June 8th 06 11:45 PM
Custom Function Call Bill Martin -- (Remove NOSPAM from address) Excel Discussion (Misc queries) 5 September 6th 05 06:14 PM
VLOOKUP formula appears in the cell I need to see the result in Shaynes Excel Discussion (Misc queries) 3 May 11th 05 11:24 PM
Lookup the latest date in a range so it appears as my result FBB Excel Discussion (Misc queries) 1 December 4th 04 03:50 AM


All times are GMT +1. The time now is 02:17 PM.

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"