1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Option Explicit
Private Sub ComboBox1_Change()
If Left(ComboBox1.Value, 1) <> "=" Then
Selection.Value = ComboBox1.Value
End If
End Sub
Private Sub ComboBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
If Left(ComboBox1.Value, 1) <> "=" Then
Selection.Value = ComboBox1.Value
Else
'Gestion des formules
Selection.FormulaLocal = ComboBox1.Value
End If
Me.ComboBox1.Visible = False
ActiveSheet.Cells(Selection.Row + 1, Selection.Column).Activate
End If
End Sub
Private Sub Worksheet_Selectionchange(ByVal Target As Range)
If ActiveSheet.Name = "AutoComplete" And _
Target.Areas.Count = 1 And Target.Rows.Count = 1 And Target.Columns.Count = 1 Then
With Me.ComboBox1
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Value = Target.Value
.Width = Target.Width
.Height = Target.Height
.Value = Target.Value
End With
Else
With Me.ComboBox1
.Visible = False
End With
End If
End Sub
'Pour gérer la touche "del" sur une cellule
Private Sub Worksheet_Change(ByVal Target As Range)
If Me.ComboBox1.Visible Then
Me.ComboBox1.Value = Target.Value
End If
End Sub |
Partager