Paste Search Dynamic
Recent pastes
FlagBestDuplicate Macro
  1. sub FlagBestDuplicate()
  2. '
  3. ' FlagBestDuplicate Macro
  4. '
  5. ' Touche de raccourci du clavier: Ctrl+h
  6. '
  7.  
  8. dim fileName as string, oldFileName as string, score as Double, oldScore as Double, bestScore as integer, bestScoreFN as string
  9.  
  10.  
  11.  
  12. a = Range("A2", Range("A2").end(xlDown)).Rows.count
  13. Range("A2").Select
  14.  
  15.    
  16. for i = 2 to a + 1
  17.     if isempty(fileName) then
  18.         fileName = Cells(i, 1).Value
  19.         score = Cells(i, 63).Value
  20.         Cells(i, 64).Value = "OK"
  21.     end if
  22.    
  23.     if isempty(bestScoreFN) then
  24.         bestScoreFN = fileName
  25.         bestScore = i
  26.     end if
  27.                    
  28.    
  29.     ' On attribue les valeurs
  30.        oldFileName = fileName
  31.         oldScore = score
  32.         fileName = Cells(i, 1).Value
  33.         score = Cells(i, 63).Value
  34.        
  35.     ' debut des conditions
  36.        if fileName = oldFileName then
  37.             if score >= oldScore then
  38.                 Cells(i, 64).Value = "OK"
  39.                 Cells(i - 1, 64).Value = "KO"
  40.                 if bestScoreFN = fileName then
  41.                     if score = Cells(bestScore, 63).Value then
  42.                         Cells(bestScore, 64).Value = "KO"
  43.                     end if
  44.                 end if
  45.                 bestScore = i
  46.                 bestScoreFN = fileName
  47.            
  48.             else
  49.                 Cells(i, 64).Value = "KO"
  50.             end if
  51.         else
  52.             Cells(i, 64).Value = "OK"
  53.         end if
  54.        
  55.  
  56. next i
  57.    
  58.    
  59.  
  60.  
  61. end sub
  62.  
Parsed in 0.007 seconds