ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming Excel worksheet function (https://www.excelbanter.com/excel-programming/283924-programming-excel-worksheet-function.html)

Stas

Programming Excel worksheet function
 
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.



Don Guillett[_4_]

Programming Excel worksheet function
 
asked elsewhere

--
Don Guillett
SalesAid Software

"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.





Chip Pearson[_2_]

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.






All times are GMT +1. The time now is 01:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com