Macro excel bug

Menator -  
 Utilisateur anonyme -
Le probleme survient où j'ai mis la flèche

Private Sub CommandButton2_Click()
Rows("1:400").Select
Selection.Delete Shift:=xlUp
Dim Ligne, Nombre As Long, r As Long
Application.ScreenUpdating = False
For Nombre = Sheets.Count To 2 Step -1
Ligne = Range("a65536").End(xlUp).Row + 1
Sheets(Nombre).Range("a1:" & Sheets(Nombre).Range("a1").SpecialCells(xlCellTypeLastCell).Address).Copy
Sheets(1).Activate
Range("A" & Ligne).Select
ActiveSheet.Paste
Next Nombre
Range("S65536").End(xlUp).Offset(-9, 1) = "9"
i = 12
Do Until Range("T" & i).Value = "9"
Select Case Range("T" & i).Value
Case "a"
i = i + 1
Case Else
Rows(i).Delete
End Select
Loop
Range("t65536").End(xlUp) = ""
ActiveSheet.PageSetup.PrintArea = Range("A1:S" & _
Range("S65536").End(xlUp).Row).Address
Range("S65536").End(xlUp).Offset(-4, 0) = "= TODAY()"

i = Range("K65536").End(xlUp).Row

Columns("B:B").Insert Shift:=xlToRight
Range("B11").FormulaR1C1 = "# Par mel."
Range("B12").FormulaR1C1 = "A - 1"
Range("B12").Select
---> Selection.AutoFill Destination:=ActiveSheet.Range("B12:B" & r), Type:=xlFillDefault
Range("B12:B" & r).Select
Columns("B:B").Select
Selection.ColumnWidth = 8.71
Range("B10:B11").Select
Range("B11").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
End Sub

2 réponses

  1. Utilisateur anonyme
     
    Bonjour,

    Bien que la variable [ r ] soit dimensionné, elle n'est pas initialisé.

    Aucune valeur ne lui est affecté ?

    Cdt

    Lupin
    0
    1. Menator
       
      Alors que dois-je faire pour pour donner la valeur de la colonne a ma variable svp ?
      0
    2. Menator
       
      Et pourquoi la variable "i" marche sans être initialisé ?
      0
    3. Menator
       
      Rows("1:400").Select
      Selection.Delete Shift:=xlUp
      Dim Ligne, Nombre As Long, r As Long
      Application.ScreenUpdating = False
      For Nombre = Sheets.Count To 2 Step -1
      Ligne = Range("a65536").End(xlUp).Row + 1
      Sheets(Nombre).Range("a1:" & Sheets(Nombre).Range("a1").SpecialCells(xlCellTypeLastCell).Address).Copy
      Sheets(1).Activate
      Range("A" & Ligne).Select
      ActiveSheet.Paste
      Next Nombre
      Range("S65536").End(xlUp).Offset(-9, 1) = "9"
      i = 12
      Do Until Range("T" & i).Value = "9"
      Select Case Range("T" & i).Value
      Case "a"
      i = i + 1
      Case Else
      Rows(i).Delete
      End Select
      Loop
      Range("t65536").End(xlUp) = ""
      ActiveSheet.PageSetup.PrintArea = Range("A1:S" & _
      Range("S65536").End(xlUp).Row).Address
      Range("S65536").End(xlUp).Offset(-4, 0) = "= TODAY()"

      i = Range("K65536").End(xlUp).Row

      -------> Columns("B:B").Insert Shift:=xlToRight
      Range("B11").FormulaR1C1 = "# Par mel."
      Range("B12").FormulaR1C1 = "A - 1"
      Range("B12").Select
      Selection.AutoFill Destination:=ActiveSheet.Range("B12:B" & i), Type:=xlFillDefault
      Range("B12:B" & i).Select
      Columns("B:B").Select
      Selection.ColumnWidth = 8.71
      Range("B10:B11").Select
      Range("B11").Activate
      With Selection
      .HorizontalAlignment = xlCenter
      .VerticalAlignment = xlCenter
      .WrapText = False
      .Orientation = 0
      .AddIndent = False
      .IndentLevel = 0
      .ShrinkToFit = False
      .ReadingOrder = xlContext
      .MergeCells = False
      End With
      Selection.Merge
      End Sub

      Oups, j'avais oublier de modifier mon r, mais ca ne marche toujours pas, maintenant il me mais un bog où j'ai mis la flèche.
      0
    4. Menator
       
      Je récapitule,

      Si j'enleve tout se qui se trouve après TODAY ca marche nickel........ J'ai pas Dim le i.... aurais-je du..........J'ai essayer de plusieurs maniere et aucune fonctionne .....j'ai perdu ma journée la dessus please help !!!
      0
  2. Utilisateur anonyme
     
    re:

    le feuille active, ou le feuille cible est difficile à localiser
    n'ayant pas les données ...

    je te recommande les mots clés

    Option Explicit

    en début de module et l'utilisation de la propriété

    Select des feuilles lors des traitements.

    ça ne t'aide pas beaucoup, mais peut-être qu'un
    autre pourra aller plus loin :-)

    Cdt

    Lupin
    0
    1. Menator
       
      Y a t'il moyen de t'envoyer le fichier ?
      0
    2. Utilisateur anonyme
       
      re:

      oui, je ne l'ai jamais fait, mais des membres ont pu m'envoyer un message
      privée ...

      clic sur mon pseudo
      onglet " message privée "

      de la on peut communiquer différemment.

      Cdt

      Lupin
      0