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

Résolu
J0K0 Messages postés 167 Statut Membre -  
J0K0 Messages postés 167 Statut Membre -
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
Configuration: Windows XP Internet Explorer 6.0

1 réponse

  1. J0K0 Messages postés 167 Statut Membre 17
     
    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