Simplifier code

castor30

XLDnaute Occasionnel
Bonjour,
J'ai fait ce code avec l'enregistreur, peut-on le simplifier ?
je vous remercie

Sub MisForm()
Range("A1").Select
ActiveCell.FormulaR1C1 = "Nom" & Chr(13) & "" & Chr(10) & "Adresse "
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "Gras"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=4, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=6, Length:=8).Font
.Name = "Times New Roman"
.FontStyle = "Italique"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B1").Select
ActiveCell.FormulaR1C1 = "Prénom" & Chr(13) & "" & Chr(10) & " Complément Adresse"
With ActiveCell.Characters(Start:=1, Length:=6).Font
.Name = "Times New Roman"
.FontStyle = "Gras"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=7, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=10, Length:=18).Font
.Name = "Times New Roman"
.FontStyle = "Italique"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("C1").Select
ActiveCell.FormulaR1C1 = "Tél Maison" & Chr(13) & "" & Chr(10) & " CP"
With ActiveCell.Characters(Start:=1, Length:=10).Font
.Name = "Times New Roman"
.FontStyle = "Gras"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=11, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=14, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "Italique"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("D1").Select
ActiveCell.FormulaR1C1 = "Tél Portable" & Chr(13) & "" & Chr(10) & " Commune"
With ActiveCell.Characters(Start:=1, Length:=12).Font
.Name = "Times New Roman"
.FontStyle = "Gras"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=13, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=15, Length:=8).Font
.Name = "Times New Roman"
.FontStyle = "Italique"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("E1").Select
ActiveCell.FormulaR1C1 = "Sel"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "Gras"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("A1:E1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub
 

JBARBE

XLDnaute Barbatruc
Bonjour à tous,
Difficile de faire un tri dans tout cette sélection de activecell :
Peut être ceci à tester :
Code:
    Sub MisForm()
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "Nom" & Chr(13) & "" & Chr(10) & "Adresse "
    With ActiveCell.Characters(Start:=1, Length:=3).Font
    .Name = "Times New Roman"
    .FontStyle = "Gras"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    With ActiveCell.Characters(Start:=4, Length:=2).Font
    .Name = "Times New Roman"
    .FontStyle = "Normal"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    With ActiveCell.Characters(Start:=6, Length:=8).Font
    .Name = "Times New Roman"
    .FontStyle = "Italique"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "Prénom" & Chr(13) & "" & Chr(10) & " Complément Adresse"
    With ActiveCell.Characters(Start:=1, Length:=6).Font
    .Name = "Times New Roman"
    .FontStyle = "Gras"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    With ActiveCell.Characters(Start:=7, Length:=3).Font
    .Name = "Times New Roman"
    .FontStyle = "Normal"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    With ActiveCell.Characters(Start:=10, Length:=18).Font
    .Name = "Times New Roman"
    .FontStyle = "Italique"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "Tél Maison" & Chr(13) & "" & Chr(10) & " CP"
    With ActiveCell.Characters(Start:=1, Length:=10).Font
    .Name = "Times New Roman"
    .FontStyle = "Gras"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    With ActiveCell.Characters(Start:=11, Length:=3).Font
    .Name = "Times New Roman"
    .FontStyle = "Normal"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    With ActiveCell.Characters(Start:=14, Length:=2).Font
    .Name = "Times New Roman"
    .FontStyle = "Italique"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "Tél Portable" & Chr(13) & "" & Chr(10) & " Commune"
    With ActiveCell.Characters(Start:=1, Length:=12).Font
    .Name = "Times New Roman"
    .FontStyle = "Gras"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    With ActiveCell.Characters(Start:=13, Length:=2).Font
    .Name = "Times New Roman"
    .FontStyle = "Normal"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    With ActiveCell.Characters(Start:=15, Length:=8).Font
    .Name = "Times New Roman"
    .FontStyle = "Italique"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    Range("E1").Select
    ActiveCell.FormulaR1C1 = "Sel"
    With ActiveCell.Characters(Start:=1, Length:=3).Font
    .Name = "Times New Roman"
    .FontStyle = "Gras"
    .Size = 10
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    Range("A1:E1").Select
    With Selection
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlBottom
    End With
    End Sub
Bonne journée !
 

Statistiques des forums

Discussions
312 203
Messages
2 086 181
Membres
103 152
dernier inscrit
Karibu