View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_5_] Patrick Molloy[_5_] is offline
external usenet poster
 
Posts: 10
Default Translating spreadsheet formula to VBA

Your question bears no relation to your initial question.

In a sheet use =MyAtan(A1,A2)
replacing MyAtan with your function name and A1 and A2 by
whatever cell references you want.
In VB

MyResult = MyAtan(Var1,Var2)


If you wnat the result in a textbox on a userform then
Textbox1.Text = Format$(MyResult,"0.0")

HTH
Patrick Molloy
Microsoft Excel MVP



-----Original Message-----
Hello,

Thanks for your help. I guess I can use the first
function. How do I call this function to that particular
textbox. I'm not linking VB with the spreadsheet but I
have designed a form using the dialog box and when I run
excel, it will popup this form.

My question is, can I use the VB function which was
suggested to me or is there another way of doing it?

Thanks.

Sheela


-----Original Message-----
First, check HELP for the correct functions.
Generally, you could use EITHER the VB function OR the
Worksheet function, so check them both out.

1) Using the VB function
Function MyATAN(V1 As Double, V2 As Double) As Double
Dim first As Double
Application.Volatile
first = Tan(V1 / V2)
MyATAN = Cos(first)
End Function

2) Using the worksheet function
Function MyATAN(V1 As Double, V2 As Double) As Double
Dim first As Double
Application.Volatile
first = Application.WorksheetFunction.Atan2(V1, V2)
MyATAN = Application.WorksheetFunction.Cosh

(first)
End Function


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
I have this formula in worksheet:

=COS(ATAN(E13/E14))

I want to create this formula in VBA but its not
available in the library.

I'm new to this VBA. I'll really appreciate if anybody
could help me out in this.

Thanks.

Sheela
.

.

.