View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default How to paste values in a spreadsheet with a VBA function

You need to passback the output to the function. Refer the example below
Getword accepts two arguments and return a string. Note the last line in the
code where the output is assigned back to the function name.

A1 = "This is a test"
B1 = GetWord(A1,3)

Function GetWord(strTemp As String, lngPos As Long) as String
'Function to return the nth word from a text string..from a cell
If InStr(Trim(strTemp), " ") = 0 Then Exit Function
lngPos = lngPos - 1
arrTemp = Split(Trim(strTemp), " ")
If lngPos UBound(arrTemp) Or lngPos < 0 Then Exit Function
GetWord = arrTemp(lngPos)
End Function


--
If this post helps click Yes
---------------
Jacob Skaria


" wrote:

Hi, I want to know how to use the instruction Range("RangeName").Value
= Output in a VBA function to paste in a spreadsheet a value which is
not the principal output of the function.

Thanks