Results 1 to 14 of 14

Finding Max Value with a Loop

Threaded View

  1. #1
    Registered User
    Join Date
    04-22-2013
    Location
    Ankara
    MS-Off Ver
    Excel 2007
    Posts
    30

    Question Finding Max Value with a Loop

    Hi all,

    I need a VBA code to find first 5 max values in the matrix. The process lasts as follows:

    1-Find the max value
    2-Write that max value in the second sheet on A1 cell
    3-Erase that max value in the matrix
    4-Find the max value
    5-Write that max value in the second sheet on A2 cell

    and go on...

    I tried to code but I encounter error messages always.

    My code for finding the first max value:

    For i=1 to 25
         For j=1 to 25
              If Cells(i,j)<Cells(i,j+1) Then
              TheMax= Cells(i,j+1)
         Next j
    
         If Cells(i,j+1)<Cells(i+1,j+1) Then
         TheMax = Cells(i+1,j+1)
    Next i
    
    Sheet2.Range("A1") = Cells(i+1,j+1)

    Thanks for helping
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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