Je soutiens Excel Downloads
Connexion
S'inscrire
Effectuez une recherche sur Excel Downloads...
Effectuez une recherche sur Excel Downloads...
Rechercher dans les titres uniquement
Par:
FORUMS
Nouveaux messages
Rechercher dans les forums
TÉLÉCHARGEMENTS
POUR LES PROFESSIONNELS
Gestion commerciale
Gestion de projets
Gestion du personnel
Tableaux de bord
Comptabilité
Immobilier
Bourse
POUR LES PARTICULIERS
Budgets et comptes
Plannings et calendriers
UTILITAIRES
LEÇONS ET TUTORIAUX
Fonctions Excel
Vba
RESSOURCES PEDAGOGIQUES
Rechercher une ressource
ACTUALITÉS
TUTOS
EXCEL
FORMULES ET FONCTIONS
VBA
POWER QUERY
POWER PIVOT
POWER BI
AUTRES APPLICATIONS
Recherche de tutos vidéos
Connexion
S'inscrire
Quoi de neuf
Effectuez une recherche sur Excel Downloads...
Effectuez une recherche sur Excel Downloads...
Rechercher dans les titres uniquement
Par:
Nouveaux messages
Rechercher dans les forums
Menu
Connexion
S'inscrire
Installer l'application
Installer
FORUMS
Questions
Forum Excel
probleme dans une macro lgn = cell.Row
JavaScript est désactivé. Pour une meilleure expérience, veuillez activer JavaScript dans votre navigateur avant de continuer.
Vous utilisez un navigateur obsolète. Il se peut que ce site ou d'autres sites Web ne s'affichent pas correctement.
Vous devez le mettre à jour ou utiliser un
navigateur alternatif
.
Répondre à la discussion
Message
<blockquote data-quote="neim" data-source="post: 20353259" data-attributes="member: 231155"><p>Bonjour à tous,</p><p></p><p>La macro ci dessous sert à copier des lignes d'une feuille pour la coller dans une autre. Ca fonctionne très bien sauf que quand je veux faire un tri sur la premiere feuille, ca ne fonctionne plus et la ligne en jaune apparait dans le debogage :</p><p></p><p>Set fd = Sheets("données")</p><p>Set fc = Sheets("Liste clients")</p><p>Set ft = Sheets("Test")</p><p>Set dico = CreateObject("Scripting.Dictionary")</p><p></p><p>Application.ScreenUpdating = False</p><p>For i = 2 To fc.Range("A" & Rows.Count).End(xlUp).Row</p><p>dico(fc.Range("A" & i).Value) = ""</p><p>Next i</p><p></p><p>'initialisation</p><p>derLn = Range("A" & Rows.Count).End(xlUp).Row</p><p>For i = derLn To 2 Step -1</p><p>If Not (dico.exists(Range("A" & i).Value) And Range("B" & i) = "") Then</p><p>Range("A" & i & ":R" & i).Delete Shift:=xlUp</p><p>End If</p><p>Next i</p><p></p><p>derLn = Range("A" & Rows.Count).End(xlUp).Row</p><p>For i = derLn To 2 Step -1</p><p>Range("A1:G1").Copy</p><p>Range("A" & i & ":G" & i).Insert Shift:=xlDown</p><p>Next i</p><p>Range("A1:G1").Delete Shift:=xlUp</p><p></p><p>'Report</p><p></p><p>For i = 3 To fd.Range("A" & Rows.Count).End(xlUp).Row</p><p>If fd.Range("C" & i) <> "" Then</p><p>Set cell = ft.Range("A:G").Find(fd.Cells(i, 3).Value, lookat:=xlWhole)</p><p><strong>lgn = cell.Row</strong></p><p>If Not cell Is Nothing Then</p><p>'If cell.Offset(2, 0) = "" Then</p><p>If Cells(lgn + 2, 2) = "" Then</p><p>cell.Offset(1, 0).Resize(1, 18).Insert Shift:=xlDown</p><p>fd.Range("A1:R1").Copy</p><p>cell.Offset(2, 0).Resize(1, 18).Insert Shift:=xlDown</p><p>Cells(lgn + 1, 1).Offset(1, 2).Delete Shift:=xlToLeft</p><p>End If</p><p>d = 0</p><p>Do Until Cells(lgn + 2 + d, 1) = ""</p><p>d = d + 1</p><p>Loop</p><p>ln = lgn + 2 + d</p><p>Range("A" & ln & ":Q" & ln).Insert Shift:=xlDown</p><p></p><p>fd.Range("A" & i & ":B" & i).Copy Range("A" & ln)</p><p>fd.Range("D" & i & ":R" & i).Copy Range("C" & ln)</p><p>End If</p><p>End If</p><p>Next i</p><p></p><p>End Sub</p><p></p><p>J'ai essayé d'ajouter cet enregistrement de macro automatique mais le probleme reste le même.</p><p></p><p>Option Explicit</p><p></p><p>Dim fd As Worksheet, fc As Worksheet, ft As Worksheet, cell As Range</p><p>Dim dico As Object</p><p>Dim i&, derLn&, lgn&, ln&, d&</p><p></p><p></p><p>Sub Planning()</p><p></p><p>Columns("A:Q").Select</p><p>ActiveWorkbook.Worksheets("données").Sort.SortFields.Clear</p><p>ActiveWorkbook.Worksheets("données").Sort.SortFields.Add2 Key:=Range( _</p><p>"C2:C280"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _</p><p>xlSortNormal</p><p>ActiveWorkbook.Worksheets("données").Sort.SortFields.Add2 Key:=Range( _</p><p>"G2:G280"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _</p><p>xlSortNormal</p><p>ActiveWorkbook.Worksheets("données").Sort.SortFields.Add2 Key:=Range( _</p><p>"F2:F280"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _</p><p>xlSortNormal</p><p>With ActiveWorkbook.Worksheets("données").Sort</p><p>.SetRange Range("A1:Q280")</p><p>.Header = xlYes</p><p>.MatchCase = False</p><p>.Orientation = xlTopToBottom</p><p>.SortMethod = xlPinYin</p><p>.Apply</p><p>End With</p><p>Range("A2").Select</p><p></p><p></p><p></p><p>Auriez vous une solution à ce problème ?</p><p></p><p></p><p>J aurais aimé aussi qu'au lancement de la macro, les mises en forme conditionnelle soit effacée avant de recopier les lignes. Est ce possible ,</p><p></p><p>Merci de votre aide</p><p></p><p>Cordialement</p></blockquote><p></p>
[QUOTE="neim, post: 20353259, member: 231155"] Bonjour à tous, La macro ci dessous sert à copier des lignes d'une feuille pour la coller dans une autre. Ca fonctionne très bien sauf que quand je veux faire un tri sur la premiere feuille, ca ne fonctionne plus et la ligne en jaune apparait dans le debogage : Set fd = Sheets("données") Set fc = Sheets("Liste clients") Set ft = Sheets("Test") Set dico = CreateObject("Scripting.Dictionary") Application.ScreenUpdating = False For i = 2 To fc.Range("A" & Rows.Count).End(xlUp).Row dico(fc.Range("A" & i).Value) = "" Next i 'initialisation derLn = Range("A" & Rows.Count).End(xlUp).Row For i = derLn To 2 Step -1 If Not (dico.exists(Range("A" & i).Value) And Range("B" & i) = "") Then Range("A" & i & ":R" & i).Delete Shift:=xlUp End If Next i derLn = Range("A" & Rows.Count).End(xlUp).Row For i = derLn To 2 Step -1 Range("A1:G1").Copy Range("A" & i & ":G" & i).Insert Shift:=xlDown Next i Range("A1:G1").Delete Shift:=xlUp 'Report For i = 3 To fd.Range("A" & Rows.Count).End(xlUp).Row If fd.Range("C" & i) <> "" Then Set cell = ft.Range("A:G").Find(fd.Cells(i, 3).Value, lookat:=xlWhole) [B]lgn = cell.Row[/B] If Not cell Is Nothing Then 'If cell.Offset(2, 0) = "" Then If Cells(lgn + 2, 2) = "" Then cell.Offset(1, 0).Resize(1, 18).Insert Shift:=xlDown fd.Range("A1:R1").Copy cell.Offset(2, 0).Resize(1, 18).Insert Shift:=xlDown Cells(lgn + 1, 1).Offset(1, 2).Delete Shift:=xlToLeft End If d = 0 Do Until Cells(lgn + 2 + d, 1) = "" d = d + 1 Loop ln = lgn + 2 + d Range("A" & ln & ":Q" & ln).Insert Shift:=xlDown fd.Range("A" & i & ":B" & i).Copy Range("A" & ln) fd.Range("D" & i & ":R" & i).Copy Range("C" & ln) End If End If Next i End Sub J'ai essayé d'ajouter cet enregistrement de macro automatique mais le probleme reste le même. Option Explicit Dim fd As Worksheet, fc As Worksheet, ft As Worksheet, cell As Range Dim dico As Object Dim i&, derLn&, lgn&, ln&, d& Sub Planning() Columns("A:Q").Select ActiveWorkbook.Worksheets("données").Sort.SortFields.Clear ActiveWorkbook.Worksheets("données").Sort.SortFields.Add2 Key:=Range( _ "C2:C280"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _ xlSortNormal ActiveWorkbook.Worksheets("données").Sort.SortFields.Add2 Key:=Range( _ "G2:G280"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _ xlSortNormal ActiveWorkbook.Worksheets("données").Sort.SortFields.Add2 Key:=Range( _ "F2:F280"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _ xlSortNormal With ActiveWorkbook.Worksheets("données").Sort .SetRange Range("A1:Q280") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With Range("A2").Select Auriez vous une solution à ce problème ? J aurais aimé aussi qu'au lancement de la macro, les mises en forme conditionnelle soit effacée avant de recopier les lignes. Est ce possible , Merci de votre aide Cordialement [/QUOTE]
Insérer les messages sélectionnés…
Vérification
Répondre
FORUMS
Questions
Forum Excel
probleme dans une macro lgn = cell.Row
Texte copié dans le presse-papier