Macro excel bug

Fermé
Menator - 6 juin 2012 à 19:19
 Utilisateur anonyme - 7 juin 2012 à 22:31
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
A voir également:

2 réponses

Utilisateur anonyme
6 juin 2012 à 20:17
Bonjour,

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

Aucune valeur ne lui est affecté ?

Cdt

Lupin
0
Alors que dois-je faire pour pour donner la valeur de la colonne a ma variable svp ?
0
Et pourquoi la variable "i" marche sans être initialisé ?
0
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
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
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
Y a t'il moyen de t'envoyer le fichier ?
0
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