création checkBox apres Coller

  • Initiateur de la discussion Initiateur de la discussion achraf26
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

achraf26

XLDnaute Occasionnel
Bonjour,
j'avais mis un macro pour quand je saisie un code dans la colonne A, un check box crée automatiquement à la colonne E,
par contre j'ai eu un soucie Quand je copie la cellule de G12:H12, à la colonne A le check box n'est pas crée automatiquement.
Quelqu'un a une solution svp
Merci
 

Pièces jointes

Re : création checkBox apres Coller

Re,

Si par copier-coller ou effacement on veut faire des modifications multiples :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, h#, g#, l#, c#
Set r = Intersect(Target, [A:A])
If r Is Nothing Then Exit Sub
If r.Count > 1000 Then 'limite à adapter...
    MsgBox "Plage trop grande !", 48
    Application.EnableEvents = False
    Application.Undo
    Application.EnableEvents = True
    Exit Sub
End If
For Each r In r 'si modifications multiples
    h = Range("E" & r.Row).Top
    g = Range("E" & r.Row).Left
    l = Range("E" & r.Row).Width
    c = g + l / 2 - 8
    If r <> "" Then
        With Me.CheckBoxes.Add(c, h, 0, 0)
            .Text = ""
            .Value = xlOff
            .LinkedCell = "F" & r.Row
            .Name = "CheckBox_E" & r.Row
        End With
    Else
        On Error Resume Next
        Me.Shapes.Range("CheckBox_E" & r.Row).Delete
        On Error GoTo 0
    End If
Next
End Sub
A+
 
Re : création checkBox apres Coller

Re,

Si par copier-coller ou effacement on veut faire des modifications multiples :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, h#, g#, l#, c#
Set r = Intersect(Target, [A:A])
If r Is Nothing Then Exit Sub
If r.Count > 1000 Then 'limite à adapter...
    MsgBox "Plage trop grande !", 48
    Application.EnableEvents = False
    Application.Undo
    Application.EnableEvents = True
    Exit Sub
End If
For Each r In r 'si modifications multiples
    h = Range("E" & r.Row).Top
    g = Range("E" & r.Row).Left
    l = Range("E" & r.Row).Width
    c = g + l / 2 - 8
    If r <> "" Then
        With Me.CheckBoxes.Add(c, h, 0, 0)
            .Text = ""
            .Value = xlOff
            .LinkedCell = "F" & r.Row
            .Name = "CheckBox_E" & r.Row
        End With
    Else
        On Error Resume Next
        Me.Shapes.Range("CheckBox_E" & r.Row).Delete
        On Error GoTo 0
    End If
Next
End Sub
A+

Bonsoir ,
j'ai pas compris le code, (si par copier/coller) ?
Merci Job
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Retour