AmardeepD
02-17-2008, 05:13 AM
Ok so continuing on from the problem i posted a couple of days earlier I have written a section of code that is giving me two problems. Firstly the code is:
Private Sub Cmdcalc_Click()
Dim ww1, bphww1, epsilon, core, ext As Double
Dim num, cellnum, filttype As Integer
num = 1
ww1 = Worksheets("Sheet1").Range("B17").Value
bphww1 = Worksheets("Sheet1").Range("B18").Value
epsilon = Worksheets("Sheet1").Range("B15").Value
filttype = Worksheets("Sheet3").Range("B2").Value
If filttype > 2 Then
core = Log(bphww1 + Sqr((bphww1 ^ 2) - 1))
For num = 1 To 15 Step 1
cellnum = 20 + (num * 2)
'higher band edge
Worksheets("Sheet1").Range("B" & cellnum).Value = 10 * Log(1 + epsilon * (Application.WorksheetFunction.Cosh((num * core) ^ 2)))
Next num
End If
num = 1
core = Log(ww1 + Sqr((ww1 ^ 2) - 1))
For num = 1 To 15 Step 1
cellnum = 19 + (num * 2)
Worksheets("Sheet1").Range("B" & cellnum).Value = 10 * Log(1 + epsilon * (Application.WorksheetFunction.Cosh((num * core) ^ 2)))
Next num
End Sub
The first problem is that even though filttype IS >2 it doesnt seem to be doing the calculations in the IF statement (or maybe just not displaying them).
The second problem confuses the problem in that it does the calculations and displays them fine right up until it comes to the last (15th) itteration when it then comes up with an error saying it cant call the Cosh function :S Needless to say this then highly confuses the first problem and points to a problem in the IF.
Thanks guys :help
(note: the maths being used in the core calculation is the mathematical basic equivalent of the Acosh function which I was asking about the other day ... i found it somewhat simpler to use)
Private Sub Cmdcalc_Click()
Dim ww1, bphww1, epsilon, core, ext As Double
Dim num, cellnum, filttype As Integer
num = 1
ww1 = Worksheets("Sheet1").Range("B17").Value
bphww1 = Worksheets("Sheet1").Range("B18").Value
epsilon = Worksheets("Sheet1").Range("B15").Value
filttype = Worksheets("Sheet3").Range("B2").Value
If filttype > 2 Then
core = Log(bphww1 + Sqr((bphww1 ^ 2) - 1))
For num = 1 To 15 Step 1
cellnum = 20 + (num * 2)
'higher band edge
Worksheets("Sheet1").Range("B" & cellnum).Value = 10 * Log(1 + epsilon * (Application.WorksheetFunction.Cosh((num * core) ^ 2)))
Next num
End If
num = 1
core = Log(ww1 + Sqr((ww1 ^ 2) - 1))
For num = 1 To 15 Step 1
cellnum = 19 + (num * 2)
Worksheets("Sheet1").Range("B" & cellnum).Value = 10 * Log(1 + epsilon * (Application.WorksheetFunction.Cosh((num * core) ^ 2)))
Next num
End Sub
The first problem is that even though filttype IS >2 it doesnt seem to be doing the calculations in the IF statement (or maybe just not displaying them).
The second problem confuses the problem in that it does the calculations and displays them fine right up until it comes to the last (15th) itteration when it then comes up with an error saying it cant call the Cosh function :S Needless to say this then highly confuses the first problem and points to a problem in the IF.
Thanks guys :help
(note: the maths being used in the core calculation is the mathematical basic equivalent of the Acosh function which I was asking about the other day ... i found it somewhat simpler to use)