Simplifier un code
c
Bonjour à tous et bonne année,
J'aurais aimé savoir s'il y avait une simplification possible de ce bout de code ?
ActiveCell = ComboBox1.Value
ActiveCell.Font.Bold = True
ActiveCell.Font.Size = 9
ActiveCell.Font.Name = "Times New Roman"
ActiveCell.HorizontalAlignment = xlCenter
ActiveCell.VerticalAlignment = xlCenter
ActiveCell.Offset(0, 1).Value = ComboBox2
ActiveCell.Offset(0, 1).Font.Bold = True
ActiveCell.Offset(0, 1).Font.Size = 9
ActiveCell.Offset(0, 1).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 1).HorizontalAlignment = xlCenter
ActiveCell.Offset(0, 1).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 2).Value = ComboBox3
ActiveCell.Offset(0, 2).Font.Bold = True
ActiveCell.Offset(0, 2).Font.Size = 9
ActiveCell.Offset(0, 2).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 2).HorizontalAlignment = xlCenter
ActiveCell.Offset(0, 2).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 3).Value = TextBox1
ActiveCell.Offset(0, 3).Font.Bold = True
ActiveCell.Offset(0, 3).Font.Size = 9
ActiveCell.Offset(0, 3).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 3).HorizontalAlignment = xlCenter
ActiveCell.Offset(0, 3).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 4).Value = TextBox9
ActiveCell.Offset(0, 4).Font.Size = 9
ActiveCell.Offset(0, 4).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 4).HorizontalAlignment = xlCenter
ActiveCell.Offset(0, 4).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 5).Value = TextBox8
ActiveCell.Offset(0, 5).Font.Size = 9
ActiveCell.Offset(0, 5).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 5).HorizontalAlignment = xlLeft
ActiveCell.Offset(0, 5).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 6).Value = TextBox7
ActiveCell.Offset(0, 6).Font.Size = 9
ActiveCell.Offset(0, 6).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 6).HorizontalAlignment = xlCenter
ActiveCell.Offset(0, 6).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 7).Value = TextBox10
ActiveCell.Offset(0, 7).Font.Size = 9
ActiveCell.Offset(0, 7).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 7).HorizontalAlignment = xlCenter
ActiveCell.Offset(0, 7).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 8).Value = TextBox5
ActiveCell.Offset(0, 8).Font.Size = 9
ActiveCell.Offset(0, 8).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 8).HorizontalAlignment = xlLeft
ActiveCell.Offset(0, 8).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 9).Value = TextBox4
ActiveCell.Offset(0, 9).Font.Size = 9
ActiveCell.Offset(0, 9).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 9).HorizontalAlignment = xlLeft
ActiveCell.Offset(0, 9).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 10).Value = TextBox3
ActiveCell.Offset(0, 10).Font.Size = 9
ActiveCell.Offset(0, 10).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 10).HorizontalAlignment = xlCenter
ActiveCell.Offset(0, 10).VerticalAlignment = xlCenter
ActiveCell.Offset(0, 11).Value = TextBox2
ActiveCell.Offset(0, 11).Font.Size = 9
ActiveCell.Offset(0, 11).Font.Name = "Times New Roman"
ActiveCell.Offset(0, 11).HorizontalAlignment = xlCenter
ActiveCell.Offset(0, 11).VerticalAlignment = xlCenter
Merci,
Cleiiim
Bonjour
Bonne année...
ci joint un essai
Fred
ActiveCell = ComboBox1.Value
ActiveCell.Offset(0, 1).Value = ComboBox2
ActiveCell.Offset(0, 2).Value = ComboBox3
ActiveCell.Offset(0, 3).Value = TextBox1
ActiveCell.Offset(0, 4).Value = TextBox9
ActiveCell.Offset(0, 5).Value = TextBox8
ActiveCell.Offset(0, 6).Value = TextBox7
ActiveCell.Offset(0, 7).Value = TextBox10
ActiveCell.Offset(0, 8).Value = TextBox5
ActiveCell.Offset(0, 9).Value = TextBox4
ActiveCell.Offset(0, 10).Value = TextBox3
ActiveCell.Offset(0, 11).Value = TextBox2
With Range(ActiveCell, ActiveCell.Offset(0, 11))
.Font.Bold = True
.Font.Size = 9
.Font.Name = "Times New Roman"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
c
Re fred2406,
Merci c'est parfait,
Je l'ai adapté comme ceci comme il y avait quelques différences entre certaines cellules :
With Range(ActiveCell, ActiveCell.Offset(0, 3))
.Font.Bold = True
.Font.Size = 9
.Font.Name = "Times New Roman"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With ActiveCell.Offset(0, 4)
.Font.Size = 9
.Font.Name = "Times New Roman"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With ActiveCell.Offset(0, 5)
.Font.Size = 9
.Font.Name = "Times New Roman"
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
End With
With Range(ActiveCell.Offset(0, 6), ActiveCell.Offset(0, 7))
.Font.Size = 9
.Font.Name = "Times New Roman"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With Range(ActiveCell.Offset(0, 8), ActiveCell.Offset(0, 9))
.Font.Size = 9
.Font.Name = "Times New Roman"
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
End With
With Range(ActiveCell.Offset(0, 10), ActiveCell.Offset(0, 11))
.Font.Size = 9
.Font.Name = "Times New Roman"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
Cleiiim