2

I am an excel noob trying to make a custom excel function that uses degrees while calculating sin of an angle.

Public Function SIND(number As Double)
Formula = "SIN(RADIANS(number))"
Formula = Replace(Formula, "number", number)
SIND = Evaluate(Formula)
End Function

So far I have this but it doesn't work

braX
  • 11,506
  • 5
  • 20
  • 33
ertucode
  • 560
  • 2
  • 13

1 Answers1

2

Here's a better way:

Public Function SIND(degrees As Double) As Double
  Dim Rads As Double
  Rads = WorksheetFunction.Radians(degrees)
  SIND = Sin(Rads)
End Function

The main problem with your way is that you were mixing string functions to do math calculations, and that's just not the best method.

braX
  • 11,506
  • 5
  • 20
  • 33