+ Reply to Thread
Results 1 to 2 of 2

Write Largest Value After Looping in Cell

  1. #1
    Registered User
    Join Date
    09-23-2014
    Location
    Bandung
    MS-Off Ver
    Office 2007
    Posts
    3

    Write Largest Value After Looping in Cell

    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.

  2. #2
    Registered User
    Join Date
    09-17-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Write Largest Value After Looping in Cell


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 12
    Last Post: 08-02-2013, 01:43 PM
  2. Howto write the looping coding between worksheets and workbooks?
    By cboys00 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-11-2012, 07:17 AM
  3. How to write a macro about Looping over collection
    By Xiaojiang in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-30-2011, 01:53 AM
  4. How to write a macro to sort many columns from largest to smallest
    By brainiack18 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2011, 03:51 PM
  5. Looping through a range:find the largest total.
    By Shawn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2005, 04:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1