#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default function


Dear all,

I have a function which return string like this:

Function strReturn(byval inputstr as string) as string

strReturn="XXX"


End Function.


How can I make this function to look like other function such
as(HLookup,Vlookup,.....) which user can use when they need.

Example = strReturn(A1)

Many thanks
Thanh Nguyen


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile: http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=510475

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default function

You already have. Just make sure that it is in a standard code module.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"thanhnguyen"
wrote in message
...

Dear all,

I have a function which return string like this:

Function strReturn(byval inputstr as string) as string

strReturn="XXX"


End Function.


How can I make this function to look like other function such
as(HLookup,Vlookup,.....) which user can use when they need.

Example = strReturn(A1)

Many thanks
Thanh Nguyen


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile:

http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=510475



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default function


Hi Bob Phillips
But when i go to worksheet and try to use that function it return
#NAME?

Please give me your email address I will send to you my funtion.
my email address is

Thanks


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile:
http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=510475

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default function


Try this:

http://www.vertex42.com/ExcelArticle...functions.html

:) !
Doc ky o muc:
"How to Create Excel User Defined Functions"

Chuc may man!


--
Rock


------------------------------------------------------------------------
Rock's Profile: http://www.excelforum.com/member.php...o&userid=29723
View this thread: http://www.excelforum.com/showthread...hreadid=510475

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default function

Put it in a general module, not a sheet module

Right click on the sheet tab and select view code === No, not here

go to the VBE, insert=Module ========= place it there.



--
Regards,
Tom Ogilvy


"thanhnguyen"
wrote in message
...

Hi Bob Phillips
But when i go to worksheet and try to use that function it return
#NAME?

Please give me your email address I will send to you my funtion.
my email address is

Thanks


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile:

http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=510475





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default function


Hi all,

Regards to follow the guides of you. I put my function in Global Module
not worksheet or workbook module, but still now slove my problem.

below is my function (I copy it from MSDN)

Function TrimSpace(ByVal CellInput As Range) As String
' This procedure trims extra space from any part of a string

Dim astrInput() As String
Dim astrText() As String
Dim strElement As String
Dim lngCount As Long
Dim lngIncr As Long
Dim returnstr As String
Dim mystr As String
Dim myspecialstr() As String

If Trim(CellInput.Value) = "" Then Exit Function
' Split passed-in string.
astrInput = Split(Trim(CellInput.Value))

' Resize second array to be same size.
ReDim astrText(UBound(astrInput))



' Initialize counter variable for second array.

lngIncr = LBound(astrInput)
' Loop through split array, looking for
' non-zero-length strings.
For lngCount = LBound(astrInput) To UBound(astrInput)
strElement = astrInput(lngCount)
If Len(strElement) 0 Then
' Store in second array.
astrText(lngIncr) = strElement
lngIncr = lngIncr + 1
End If
Next

' Resize new array.
ReDim Preserve astrText(LBound(astrText) To lngIncr - 1)

' Join new array to return string.
returnstr = Join(astrText)

End Function


When I tried with formular =TrimSpace(A1) but nothing happen.

Best regards,

Thanh Nguyen


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile: http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=510475

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default function


Sorry, not solve my problem!


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile: http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=510475

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default function

If you were able to put

=TrimSpace(A1)

in a cell and it returned the values in A1, then that did solve your problem
in terms of getting the function to work.

If it returned #Value, then there is a problem either internal to the
function or in the argument

If it said something like unkown name, then the problem isn't solved.

If it just returned the string in cell A1, then did the string in A1 have
extra spaces in it.

In A1 put in

=" the big dog "

the function should then return

the big dog

--
Regards,
Tom Ogilvy


"thanhnguyen"
wrote in message
...

Sorry, not solve my problem!


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile:

http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=510475



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default function


But when I put =TrimSpace(A1) then nothing happen.

B1=TrimSpace(A1)

I tried to press Shift+F3 and insert user function but the result is
same.

"Bótay.com" is in vietnamese:)

Thanh Nguyen


--
thanhnguyen
------------------------------------------------------------------------
thanhnguyen's Profile: http://www.excelforum.com/member.php...o&userid=30502
View this thread: http://www.excelforum.com/showthread...hreadid=510475

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
Excel Data Validation/Lookup function does function correcty Kirkey Excel Worksheet Functions 2 May 25th 09 09:22 PM
copy of excel file not showing formulal/function in the function b oaallam Excel Discussion (Misc queries) 4 September 6th 07 01:20 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 03:51 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"