Déchiffrer une marco

Fermé
s.elmortaji Messages postés 50 Date d'inscription dimanche 28 février 2016 Statut Membre Dernière intervention 9 août 2016 - 6 avril 2016 à 15:05
melanie1324 Messages postés 1505 Date d'inscription vendredi 25 mai 2007 Statut Membre Dernière intervention 31 janvier 2018 - 9 avril 2016 à 21:13
Bonjour à tous,

Je souhaite déchiffrer une macro pour que je puisse l'appliquer à d'autres domaines, mais je n'y arrive pas (c'est pas qui l'ai fait de base).
Voilà et comme je suis nulle en macro ben je n'y arrive pas.
La macro utilisée est très longue :

Sub PAU_complétude_Eqts()
Sheets("Antennes").Select

Dim Ant() As String
ReDim Ant(15)

For a = 1 To 15
Ant(a) = Cells(a, 1)
Next

MsgBox " antenne 11 : " & Ant(11)

Sheets("F_Eqts_PAU").Select
Dim fa() As String
Dim fam() As String
ReDim fa(29)
ReDim fam(15, 29)

For b = 1 To 29
fa(b) = Cells(3, 1 + b)
Next

For a = 1 To 15
For b = 1 To 29
If Cells(a + 3, 1 + b) = "oui" Then fam(a, b) = "1"
If Cells(a + 3, 1 + b) = "sup" Then fam(a, b) = "2"
If Cells(a + 3, 1 + b) = "non" Then fam(a, b) = "3"
' End If
Next
Next


'***** Ecriture des résultats pour vérification *****

For b = 1 To 29
Cells(24, 1 + b) = fa(b)
Next

For a = 1 To 15
For b = 1 To 29
Cells(23, 1 + b) = b
Cells(a + 24, 1 + b) = fam(a, b)
Next
Next


Sheets("Export_PAU").Select

' ***** compter les lignes *****
j = 8
While Not Cells(j, 2) = ""
j = j + 1
Wend
L1 = j - 1

MsgBox "Le dernier enregistrement est en ligne : " & L1


' Nombre d'attributs à renseigner ATT

Dim PAU() As Long
ReDim PAU(21)

Dim ATU() As Long
ReDim ATU(21, 15)
Dim ATR() As Long
ReDim ATR(21, 15)


' ***** Compter les attributs génériques *****

For b = 8 To L1
For d = 1 To 15
If Cells(b, 1) = Ant(d) And Not Cells(b, 10) Like "*-ENS" Then
PAU(d) = PAU(d) + 1
End If
Next
Next


' ***** Nombre d'attributs renseignés par antenne ATT *****

Dim ATT() As Long
ReDim ATT(21, 15)

For a = 8 To L1
For i = 1 To 13
For d = 1 To 15
If Cells(a, 1) = Ant(d) And Not Cells(a, 10) Like "*-ENS" Then
If Cells(a, 12 + i) <> "" Then
ATT(d, i) = ATT(d, i) + 1
End If
End If
Next
Next
Next

For a = 8 To L1
For i = 1 To 29
If Cells(a, 7) = fa(i) And Not Cells(a, 10) Like "*-ENS" Then
For j = 1 To 15
If fam(j, i) = "1" Then
Cells(a, 20 + j).Interior.Color = RGB(204, 229, 255)
For b = 1 To 15
If Cells(a, 1) = Ant(b) Then
ATU(b, j) = ATU(b, j) + 1
End If
Next
End If
If fam(j, i) = "1" And Cells(a, 20 + j) <> "" Then
For b = 1 To 15
If Cells(a, 1) = Ant(b) Then
ATR(b, j) = ATR(b, j) + 1
End If
Next
End If
If fam(j, i) = "" Then
'Cells(a, 20 + j).Interior.Color = RGB(250, 200, 50)
Cells(a, 20 + j) = ""
End If
If fam(j, i) = "2" Then
Cells(a, 7).Interior.Color = RGB(255, 0, 0)
End If
If fam(j, i) = "3" Then
Cells(a, 7).Interior.Color = RGB(255, 140, 0)
End If
Next
End If
Next
Next

' ***** Ecriture des données Philippe PIERRE *****

Sheets("PAU_Synthèse_PPIERRE").Select
' **** 1 = CLERMONT FD *****
Cells(11, 2) = PAU(1)
For s = 1 To 8
Cells(10 + s, 3) = ATT(1, s)
Next
For s = 1 To 5
Cells(18 + s, 2) = ATU(1, s)
Cells(18 + s, 3) = ATR(1, s)
Next

' **** 2 = GD LYON *****
Cells(11, 6) = PAU(2)
For s = 1 To 8
Cells(10 + s, 7) = ATT(2, s)
Next
For s = 1 To 5
Cells(18 + s, 6) = ATU(2, s)
Cells(18 + s, 7) = ATR(2, s)
Next

' **** 3 = ST ALBAN *****
Cells(11, 10) = PAU(3)
For s = 1 To 8
Cells(10 + s, 11) = ATT(3, s)
Next
For s = 1 To 5
Cells(18 + s, 10) = ATU(3, s)
Cells(18 + s, 11) = ATR(3, s)
Next


' ***** Ecriture des données SPARADES *****

Sheets("PAU_Synthèse_SPARADES").Select

' **** 4 = BUGEY *****
Cells(11, 2) = PAU(4)
For s = 1 To 8
Cells(10 + s, 3) = ATT(4, s)
Next
For s = 1 To 5
Cells(18 + s, 2) = ATU(4, s)
Cells(18 + s, 3) = ATR(4, s)
Next


' **** 5 = DEUX SAVOIE *****
Cells(11, 6) = PAU(5)
For s = 1 To 8
Cells(10 + s, 7) = ATT(5, s)
Next
For s = 1 To 5
Cells(18 + s, 6) = ATU(5, s)
Cells(18 + s, 7) = ATR(5, s)
Next

' **** 6 = GRENOBLE *****
Cells(11, 10) = PAU(6)
For s = 1 To 8
Cells(10 + s, 11) = ATT(6, s)
Next
For s = 1 To 5
Cells(18 + s, 10) = ATU(6, s)
Cells(18 + s, 11) = ATR(6, s)
Next


' ***** Ecriture des données PPERRIN *****

Sheets("PAU_Synthèse_PPERRIN").Select
' **** 7 = DALKIA 1 *****
Cells(11, 2) = PAU(7)
For s = 1 To 8
Cells(10 + s, 3) = ATT(7, s)
Next
For s = 1 To 5
Cells(18 + s, 2) = ATU(7, s)
Cells(18 + s, 3) = ATR(7, s)
Next

' **** 8 = DALKIA 2 *****
Cells(11, 6) = PAU(8)
For s = 1 To 8
Cells(10 + s, 7) = ATT(8, s)
Next
For s = 1 To 5
Cells(18 + s, 6) = ATU(8, s)
Cells(18 + s, 7) = ATR(8, s)
Next

' **** 9 = DALKIA 3 *****
Cells(11, 10) = PAU(9)
For s = 1 To 8
Cells(10 + s, 11) = ATT(9, s)
Next
For s = 1 To 5
Cells(18 + s, 10) = ATU(9, s)
Cells(18 + s, 11) = ATR(9, s)
Next

' **** 10 = DALKIA 4 *****
Cells(28, 2) = PAU(10)
For s = 1 To 8
Cells(27 + s, 3) = ATT(10, s)
Next
For s = 1 To 5
Cells(35 + s, 2) = ATU(10, s)
Cells(35 + s, 3) = ATR(10, s)
Next

' **** 11 = DALKIA 5 *****
Cells(28, 6) = PAU(11)
For s = 1 To 8
Cells(27 + s, 7) = ATT(11, s)
Next
For s = 1 To 5
Cells(35 + s, 6) = ATU(11, s)
Cells(35 + s, 7) = ATR(11, s)
Next


' ***** Ecriture Synthèse PAU *****

Sheets("Synthèse_PAU").Select

' **** *****
Cells(2, 2) = 0
For a = 1 To 21
Cells(2, 2) = Cells(2, 2) + PAU(a)
Next a
For s = 1 To 8
For b = 1 To 21
Cells(1 + s, 3) = Cells(1 + s, 3) + ATT(b, s)
Next
Next
For s = 1 To 5
For a = 1 To 21
Cells(9 + s, 2) = Cells(9 + s, 2) + ATU(a, s)
Cells(9 + s, 3) = Cells(9 + s, 3) + ATR(a, s)
Next
Next



Je pense que je dois vous joindre le fichier, ca me semble compliqué de comprendre comme ca. Vous me dites si besoin.

merci

1 réponse

melanie1324 Messages postés 1505 Date d'inscription vendredi 25 mai 2007 Statut Membre Dernière intervention 31 janvier 2018 154
9 avril 2016 à 21:13
Hello,

sans le fichier ca paraît un peu compliqué.

Tu peux exécuter la macro en appuyant sur la touche F9.
cela permet d'exécuter ligne par ligne et te permettra de mieux comprendre ce qu'elle fait.
0