I used the loop code below in Microsoft Visual Studio 8 and am trying to get it to work in Excel’s VBA. The Cos and Sin function seem to be the problem, is there any way to get it to work?
Thanks Sandy.
My only thought was to some how get Fun_3 by writing the Fun_1 and Fun_2 formula into Excel during a Loop until Fun_1 = 0??![]()
Sub TestInputs() Dim Fun_1 As Double Dim Fun_2 As Double Dim Fun_3 As Double Dim Rise As Double Dim TempRad As Double Dim InLength As Double Dim RadiusNew As Double Rise = Range("M231").Value InLength = Range("M231").Value AproxRad = Range("O232").Value TempRad = AproxRad Do Fun_1 = 1 - (Rise / TempRad) - (WorksheetFunction.Cos(InLength / 2 / TempRad)) Fun_2 = (Rise / (TempRad ^ 2)) - ((WorksheetFunction.Sin(InLength / 2 / TempRad)) * InLength / 2 / TempRad ^ 2) Fun_3 = TempRad - (Fun_1 / Fun_2) RadiusNew = Fun_3 TempRad = RadiusNew Loop Until Fun_1 = 0 Range("O233") = RadiusNew End Sub
Bookmarks