View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson[_2_] Chip Pearson[_2_] is offline
external usenet poster
 
Posts: 95
Default Programming Excel worksheet function

Stas,

Try something like the following:

Sub Extract()
Dim Pos1 As Long
Dim Pos2 As Long
Dim S As String
Dim X1 As Variant
Dim X2 As Variant
S = ActiveCell.Formula
Pos1 = InStr(1, S, "(")
Pos2 = InStr(Pos1, S, ",")
X1 = Mid(S, Pos1 + 1, Pos2 - Pos1 - 1)
Pos1 = Pos2
Pos2 = InStr(Pos1, S, ")")
X2 = Mid(S, Pos1 + 1, Pos2 - Pos1 - 1)
Debug.Print X1, X2
End Sub

This will work only if the parameters to MyFunc are simple,
non-calculated values.


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



"Stas" wrote in message
...
Hello all!
I need extract all parameters from my function.
How I must do it?
For example I have function
function myfunc(byref a, b as double) as double
...
end function

sub fillcell
ActiveCell.FormulaR1C1 = "=myfunc(10,100)"
end sub

When I start sub "extract" I must extract (a and b parameter

from function
of Activecell)
sub extract()
...
xA=a
xB=b
end sub
Thanks.
Stas.