Hi, I'm fairly new to this, I'm doing an assessment and I'm having a bit of trouble grasping how to do piecewise functions on VBA. I'm using BLOCK IFs to do this.
Heres my work so far:
x = [A2].Value
If (x <= 0) And (x < 90) Then
fx = Sin(x)
ElseIf (x >= 90) And (x < 180) Then
fx = -4 * Cos(x)
ElseIf (x <= 180) And (x < 270) Then
fx = SQRT((Sin(x) + 2) ^ 2 + 1)
ElseIf (x <= 270) And (x < 360) Then
fx = SIN( x )/2)*SQRT((SIN( x )+5)
End If
[B2].Value = fx
End Sub
It just wont seem to work when I try it, and I think it's to do with the SIN and COS etc in it, just I'm not sure. If anyone can help me out I'd be so grateful! Also I do know that I should be using radians, but at the moment I'm just trying to get it work and I'll deal with that sort of stuff afterwards.
Thanks again!
Heres my work so far:
x = [A2].Value
If (x <= 0) And (x < 90) Then
fx = Sin(x)
ElseIf (x >= 90) And (x < 180) Then
fx = -4 * Cos(x)
ElseIf (x <= 180) And (x < 270) Then
fx = SQRT((Sin(x) + 2) ^ 2 + 1)
ElseIf (x <= 270) And (x < 360) Then
fx = SIN( x )/2)*SQRT((SIN( x )+5)
End If
[B2].Value = fx
End Sub
It just wont seem to work when I try it, and I think it's to do with the SIN and COS etc in it, just I'm not sure. If anyone can help me out I'd be so grateful! Also I do know that I should be using radians, but at the moment I'm just trying to get it work and I'll deal with that sort of stuff afterwards.
Thanks again!