1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| REM ***** BASIC *****
Sub Total_maxi
Dim Doc as object
Dim Feuille1 as object
Dim Feuille2 as object
Dim col as integer
Dim lig as integer
Dim Note(500) as double
Dim Total_cible as double
Dim Total_maxi as double
Dim div as integer
Dim division(200,500) as double
Doc = thiscomponent
Feuille1 = Doc.Sheets.getByIndex(0)
Feuille2 = Doc.Sheets.getByIndex(1)
Total_cible = Feuille1.getCellByPosition(5,3).value
rem ------ Mise à zéro de la partie résultat des deux feuilles
Feuille1.getCellByPosition(5,5).value = 0
Feuille2.getCellByPosition(5,5).value = 0
rem ------ Rangement des notes par diviseur
max = 400
div = Feuille1.getCellByPosition(5,8).value
for lig = 14 to max+14
Note(lig) = Feuille1.getCellByPosition(1,lig).value
for a = 1 to div
if Note(lig) < Total_cible*a/div then
if Note(lig) >= Total_cible*a/div - Total_cible*1/div then
Feuille1.getCellByPosition(2+a,lig).value = Note(lig)
division(a,lig) = Note(lig)
endif
endif
next
next
rem ------- Selection des notes de la plus grande à la plus petite
a = div/2
do while a > 0
for lig = 9 to max
if division(a,lig) > 0 then
if Total_maxi + division(a,lig) < Total_cible then
Total_maxi = Total_maxi + division(a,lig)
Feuille2.getCellByPosition(a+2,lig).value = division(a,lig)
endif
endif
next
a = a - 1
loop
rem ------- Affichage du résultat et reprise des données sur la deuxième feuille
Feuille1.getCellByPosition(5,5).value = Total_maxi
Feuille2.getCellByPosition(5,5).value = Total_maxi
Feuille2.getCellByPosition(5,3).value = Total_cible
Feuille2.getCellByPosition(5,8).value = div
End Sub |
Partager