VBA ne fonctionne pas
K
Bonjour,
J'ai un code qui ne fonctionne plus. Seulement la dernière partie ne fonctionne pas.
Je n'arrive pas à trouver ce qui ne va pas.
Pouvez-vous m'aider?
Merci beaucoup. Karine
Option Explicit
Sub Worksheet_Activate()
Dim DL%, L%, Ind%, Col%
Application.ScreenUpdating = False
[C11:M36].ClearContents: [C79:M120].ClearContents:
' Traitement Corbeilles
With Sheets("SERIE 800D")
DL = .Range("E65500").End(xlUp).Row
' Choix corbeille
If LCase(.Range("H8")) = "x" Then
[C11] = .[E8]: [M11] = .[E9]
ElseIf LCase(.Range("P8")) = "x" Then
[C11] = .[M8]: [M11] = .[M9]
ElseIf LCase(.Range("Y8")) = "x" Then
[C11] = .[V8]: [M11] = .[V9]
Else
Exit Sub ' car pas de choix effectué
End If
Ind = 12
' Corbeille 1
Col = 8
For L = 27 To 50
' For L = 27 To DL
If LCase(.Cells(L, Col)) = "x" Then
Cells(Ind, "C") = .Cells(L, Col - 6)
Cells(Ind, "D") = .Cells(L, Col - 5)
Cells(Ind, "M") = .Cells(L, Col - 3)
Ind = Ind + 1
If Ind = 36 Then Exit For ' On sort de la boucle
End If
Next L
' Corbeille 2
Col = 16
For L = 27 To 50
' For L = 27 To DL
If LCase(.Cells(L, Col)) = "x" Then
Cells(Ind, "C") = .Cells(L, Col - 6)
Cells(Ind, "D") = .Cells(L, Col - 5)
Cells(Ind, "M") = .Cells(L, Col - 3)
Ind = Ind + 1
If Ind = 36 Then Exit For ' On sort de la boucle
End If
Next L
' Corbeille 3
Col = 25
For L = 27 To 50
' For L = 27 To DL
If LCase(.Cells(L, Col)) = "x" Then
Cells(Ind, "C") = .Cells(L, Col - 7)
Cells(Ind, "D") = .Cells(L, Col - 6)
Cells(Ind, "M") = .Cells(L, Col - 3)
Ind = Ind + 1
If Ind = 36 Then Exit For ' On sort de la boucle
End If
Next L
End With
' Ne fonctionne plus à partir d'ICI
' Traitement Options
With Sheets("Options Tanguay 2022")
DL = .Range("A65500").End(xlUp).Row
Ind = 79
For L = 5 To DL
If LCase(.Cells(L, "G")) = "x" Then
Cells(Ind, "C") = .Cells(L, "A")
Cells(Ind, "D") = .Cells(L, "B")
Cells(Ind, "M") = .Cells(L, "E")
Ind = Ind + 1
If Ind = 111 Then Exit For ' On sort de la boucle
End If
Next L
End With
Application.ScreenUpdating = True
End SubEdit modo : code mis entre balises, merci d'y faire attention la prochaine fois
Invité
Bonjour Karine,
Je suis étonné que ce code est pu fonctionner un jour
Quand je vois par exemple
Cells(Ind, "C") = .Cells(L, Col - 6)Avec le point devant une instruction fait référence à l'objet conteneur
Sans point cela fait référence à la feuille active
Donc dans le lignes de fin, que voulez-vous faire exactement ?
A+