Formule qui s'efface apres macro

Dakota

XLDnaute Nouveau
Bonsoir,

J'ai 2 colonnes avec formules sur un grand nombre de lignes, qui recopie le résultat d'une macro, à chaque fois que j'active la macro, les formules s'efface !!! mais pas sur toute les lignes ????

Avez vous déjà eu le soucis ? une idée pour y remédier.

J'ai essayer plusieurs formules rien n'y fait, cela vient bien du fait macro/formule apparemment.

Merci pour votre aide
Cordialement
 

Dakota

XLDnaute Nouveau
Voila mon code, je précise que celui-ci fonctionne très bien, mon soucis se passe avec 2 autres colonnes ( qui ne sont pas dans la macro), mais qui se sert des résultats de la macro.

Sub test()
Dim F1 As Range
Dim F2 As Range
Dim F3 As Range
Dim F4 As Range

Dim i%, j%, k%, l%, m%, col%

Dim DL As Long
DL = Sheets("Arrivées").Range("A" & Rows.Count).End(xlUp).Row
Set F1 = Sheets("blanc").Range("A7:U7")
Set F2 = Sheets("rouge").Range("A7:U7")
Set F3 = Sheets("bleu").Range("A7:U7")
Set F4 = Sheets("vert").Range("A7:U7")
Sheets("blanc").Range("AA7:AF" & DL).ClearContents
Sheets("blanc").Range("AA7:AD" & DL).Font.ColorIndex = 1
Application.Calculation = xlCalculationManual
For l = 1 To DL - 1
col = 33
For j = 7 To 21 Step 4
For k = 7 To 21 Step 4
For m = 7 To 21 Step 4
If F2(l, j).Value = F3(l, k).Value And F2(l, j).Value = F4(l, m).Value Then
F1(l, col).Value = F2(l, j).Value
If F1(l, col).Value = F1(l, 7).Value Then
F1(l, 27).Value = F1(l, col).Value
F1(l, col).Value = ""
End If
If F1(l, col).Value = F1(l, 11).Value Then
F1(l, 28).Value = F1(l, col).Value
F1(l, col).Value = ""
End If
If F1(l, col).Value = F1(l, 15).Value Then
F1(l, 29).Value = F1(l, col).Value
F1(l, col).Value = ""
End If
If F1(l, col).Value = F1(l, 19).Value Then
F1(l, 30).Value = F1(l, col).Value
F1(l, col).Value = ""
End If

F1(l, 31).Value = F1(l, 31).Value + F2(l, j + 1).Value
F1(l, 32).Value = F1(l, 32).Value + F2(l, j + 2).Value
col = col + 1
End If
Next m
Next k
Next j
Next l
For col = 33 To 36
For l = 1 To DL - 1
If F1(l, col) <> "" Then
If F1(l, 27) = "" Then
F1(l, 27) = F1(l, col)
F1(l, 27).Font.ColorIndex = 3
F1(l, col) = ""
Else
If F1(l, 28) = "" Then
F1(l, 28) = F1(l, col)
F1(l, 28).Font.ColorIndex = 3
F1(l, col) = ""
Else
If F1(l, 29) = "" Then
F1(l, 29) = F1(l, col)
F1(l, 29).Font.ColorIndex = 3
F1(l, col) = ""
Else
If F1(l, 30) = "" Then
F1(l, 30) = F1(l, col)
F1(l, 30).Font.ColorIndex = 3
F1(l, col) = ""
End If
End If
End If
End If
End If
Next l
Next col
Application.Calculation = xlCalculationAutomatic
End Sub
 
Dernière édition:

Bernard_XLD

XLDnaute Barbatruc
Membre du Staff
Bonjour le forum, Dg62, Dakota

Dakota
sans fichier et sans savoir ce qui est effacé, je dirais
DL = Sheets("Arrivées").Range("A" & Rows.Count).End(xlUp).Row
et après
Sheets("blanc").Range("AA7:AF" & DL).ClearContents

pour la solution, je fais comme toi, devines.

Bien cordialement
 

dg62

XLDnaute Barbatruc
re,

je pense que votre problème vient de cette boucle :
Code:
For col = 33 To 36
    For l = 1 To DL - 1
      If F1(l, col) <> "" Then
        If F1(l, 27) = "" Then
          F1(l, 27) = F1(l, col)
          F1(l, 27).Font.ColorIndex = 3
          F1(l, col) = ""
          Else
          If F1(l, 28) = "" Then
            F1(l, 28) = F1(l, col)
            F1(l, 28).Font.ColorIndex = 3
            F1(l, col) = ""
            Else
            If F1(l, 29) = "" Then
              F1(l, 29) = F1(l, col)
              F1(l, 29).Font.ColorIndex = 3
              F1(l, col) = ""
              Else
              If F1(l, 30) = "" Then
                F1(l, 30) = F1(l, col)
                F1(l, 30).Font.ColorIndex = 3
                F1(l, col) = ""
              End If
            End If
          End If
        End If
      End If
    Next l
  Next col

@+
 

Discussions similaires

Statistiques des forums

Discussions
312 104
Messages
2 085 335
Membres
102 865
dernier inscrit
FreyaSalander