[Excel]Nom de la dernière feuille utilisée

Résolu/Fermé
J0K0 Messages postés 163 Date d'inscription lundi 7 mai 2007 Statut Membre Dernière intervention 19 juillet 2019 - 13 nov. 2009 à 00:23
J0K0 Messages postés 163 Date d'inscription lundi 7 mai 2007 Statut Membre Dernière intervention 19 juillet 2019 - 13 nov. 2009 à 00:51
Bonsoir,

Je cherche à connaître comment mettre le nom de la dernière feuille utilisée, ou comme mon cas où toutes mes feuilles sont numérotées de 0 à l'infini, prendre le plus grand nombre.
Voici une macro faite pour insérer une ligne et justement prendre le contenu de la dernière feuille active à la ligne 6 :

Sub Macro7()

Sheets("recapitulatif").Select
Rows("5:5").Select
Selection.Insert Shift:=xlDown
Range("A5:AL5").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A5:AL5").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
ActiveCell.FormulaR1C1 = "='2'!R[1]C"
Range("A6:AL6").Select
End Sub

En réalité, ce qu'il me faut est à la fin :
--> ActiveCell.FormulaR1C1 = "='2'!R[1]C"
Range("A6:AL6").Select

Merci
A voir également:

1 réponse

J0K0 Messages postés 163 Date d'inscription lundi 7 mai 2007 Statut Membre Dernière intervention 19 juillet 2019 17
13 nov. 2009 à 00:51
RE,

en fait, j'ai trouvé une autre astuce qui pour l'instant me plait assez, mais j'ai une erreur :

Sub Macro7()
ActiveSheet.Range("A6:AL6").Copy
Sheets("recapitulatif").Select
Rows("5:5").Select
Selection.Insert Shift:=xlDown
Range("A5:AL5").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A5:AL5").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
'ActiveCell.FormulaR1C1 = "='2'!R[1]C"
ActiveSheet.Range("A6:AL6").Paste
'Range("A6:AL6").Select
End Sub

Cette erreur se situe à la fin :
ActiveSheet.Range("A6:AL6").Paste

Une idée ? merci !
0