VBA:Copier formule dans col. AK jusqu'à dernière cell de A

Résolu/Fermé
BILLING Messages postés 162 Date d'inscription vendredi 4 mai 2012 Statut Membre Dernière intervention 31 mars 2021 - 1 mars 2016 à 16:14
BILLING Messages postés 162 Date d'inscription vendredi 4 mai 2012 Statut Membre Dernière intervention 31 mars 2021 - 2 mars 2016 à 21:29
Bonjour,

J'ai cette petite macro qui ne fonctionne pas. Je crois être tout près de mon but mais je n'y arrive pas.

Je veux qu'une formule que j'ai créée se copie automatiquement dans les cellules de la colonne AK tant qu'il y a des données dans les cellules de la colonne A.

Sub S1CargoTonnes()
'
'
Dim Derlig As Integer

With ActiveSheet
Derlig = .Columns("A").Find("*", , , , , xlPrevious).Row
With Range("AK2")
.FormulaLocal = "=SI(OU($L2='DRDGE';$L2='WKBGE');" - ";SI(NON(ESTERREUR(RECHERCHEV(DROITE($L2;2);'Matrice S1'!$A$19:$B$30;2;FAUX)));RECHERCHEV(DROITE($L2;2);'Matrice S1'!$A$19:$B$30;2;FAUX);" - "))"
.AutoFill Destination:=.Range("A2:A" & Derlig)
End With
End With

End Sub


Voici mon fichier échantillon: https://www.cjoint.com/c/FCbpmPGLOzE



Merci

1 réponse

Gyrus Messages postés 3334 Date d'inscription samedi 20 juillet 2013 Statut Membre Dernière intervention 9 décembre 2016 523
1 mars 2016 à 16:36
Bonjour,

Sub S1CargoTonnes()
Dim Derlig As Integer
With ActiveSheet
Derlig = .Columns("A").Find("*", , , , , xlPrevious).Row
With .Range("AK2")
.FormulaLocal = "=SI(OU($L2=""DRDGE"";$L2=""WKBGE"");"" - "";SI(NON(ESTERREUR(RECHERCHEV(DROITE($L2;2);'Matrice S1'!$A$19:$B$30;2;FAUX)));RECHERCHEV(DROITE($L2;2);'Matrice S1'!$A$19:$B$30;2;FAUX);"" - ""))"
.AutoFill Destination:=.Resize(Derlig - 1)
End With
End With
End Sub

A+
0
BILLING Messages postés 162 Date d'inscription vendredi 4 mai 2012 Statut Membre Dernière intervention 31 mars 2021 48
1 mars 2016 à 19:03
Merci Gyrus,

Ça fonctionne parfaitement.

eLise
0
BILLING Messages postés 162 Date d'inscription vendredi 4 mai 2012 Statut Membre Dernière intervention 31 mars 2021 48
2 mars 2016 à 21:29
Bonjour Gyrus,

Peux-tu m'aider avec cette macro? Elle prend trop de temps et je crois qu'en ajoutant le fameux
 Derlig = .Columns("A").Find("*", , , , , xlPrevious).Row
ça raccourcirait le temps d'exécution.

J'ai tenté de l'insérer dans le code suivant:
Sub LeMois()
DateEntry = 19 ' 1 egal colonne S
For L = 2 To Cells(Rows.Count, DateEntry).End(xlUp).Row
Range("AJ" & L).NumberFormat = "@"
Range("AJ" & L).Value = Left(Cells(L, DateEntry), 4) & "-" & Mid(Cells(L, DateEntry), 5, 2) & "-" & Right(Cells(L, DateEntry), 2)
Range("AK" & L).Value = Application.Proper(Format(DateSerial(Left(Cells(L, DateEntry), 4), Mid(Cells(L, DateEntry), 5, 2), Right(Cells(L, DateEntry), 2)), "mmmm"))
Next
End Sub


Mais honnêtement je ne sais pas où exactement je dois l'insérer.

Peux-tu m'aider?

Merci

eLise,
0