Hello excel forum member.
Could you help me?
I have tried my best to compute this value, but I can't get it right.
I want to iterate some data and I want to write the largest value in cell at the next iterate. But the result isn't.
Help me. This is the VBA code
[CODE]
Sub Menghitung_Sound_Pressure_Level()
'Sub prosedur untuk menghitung SPL _
dan menampilkan nilai SPL yang paling tinggi pada sheet _
untuk semua posisi terbang
Dim i, j, k, D As Integer
Dim A, Pe0, SPL(0 To 958) As Double
A = Range("D3").Value
Peo = Worksheets("A(320,738,ATR,319)").Range("C23").Value
D = 2 ^ 0.5
'Langsung Menghitung SPL
For i = 0 To 958
For j = 0 To 845
For k = 0 To 400
If i > 0 Then
SPL(i) = 10 * WorksheetFunction.Log10(((A / (((((Worksheets("Flight Path (x,y,z)").Cells(11 + i, 2).Value) - (Worksheets("Ground SPL").Cells(11 + j, 2).Value)) ^ 2 + _
((Worksheets("Flight Path (x,y,z)").Cells(11 + i, 3).Value) - (Worksheets("Ground SPL").Cells(10, 3 + k).Value)) ^ 2 + _
((Worksheets("Flight Path (x,y,z)").Cells(11 + i, 4).Value) - (Worksheets("Ground (x,y,z)").Cells(11 + j, 3 + k).Value)) ^ 2) ^ 0.5) * D)) ^ 2) / (Peo ^ 2))
If SPL(i) > SPL(i - 1) Then
Worksheets("Ground SPL").Cells(11 + j, 3 + k).Value = SPL(i)
Else
Worksheets("Ground SPL").Cells(11 + j, 3 + k).Value = SPL(i - 1)
End If
Else
'Menghitung Ground SPL
SPL(i) = 10 * WorksheetFunction.Log10(((A / (((((Worksheets("Flight Path (x,y,z)").Cells(11 + i, 2).Value) - (Worksheets("Ground SPL").Cells(11 + j, 2).Value)) ^ 2 + _
((Worksheets("Flight Path (x,y,z)").Cells(11 + i, 3).Value) - (Worksheets("Ground SPL").Cells(10, 3 + k).Value)) ^ 2 + _
((Worksheets("Flight Path (x,y,z)").Cells(11 + i, 4).Value) - (Worksheets("Ground (x,y,z)").Cells(11 + j, 3 + k).Value)) ^ 2) ^ 0.5) * D)) ^ 2) / (Peo ^ 2))
Worksheets("Ground SPL").Cells(11 + j, 3 + k).Value = SPL(i)
End If
Next k
Next j
Next i
End Sub
[END OF CODE]
I think, the problem is the method for save the newest SPL value and compare it to the last SPL. And if the newest SPL value is larger, then it will write to the cell. But i can't find the method.
Bookmarks