Erreur 1004

Bonjour tout le monde,

J’ai un problème avec un code vba.

J’ai ce code :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 2017/8/15
Dim derligne As Long
derligne = Range("A" & Rows.Count).End(xlUp).Row

If Not Intersect(Target, Range("C8:C" & derligne)) Is Nothing Then
    Dim xCombox As OLEObject
    Dim xStr As String
    Dim xWs As Worksheet
    Set xWs = Application.ActiveSheet
    On Error Resume Next
    Set xCombox = xWs.OLEObjects("TempCombo")
    With xCombox
        .ListFillRange = ""
        .LinkedCell = ""
        .Visible = False
    End With
    If Target.Validation.Type = 3 Then
        Target.Validation.InCellDropdown = False
        Cancel = True
        xStr = Target.Validation.Formula1
        xStr = Right(xStr, Len(xStr) - 1)
        If xStr = "" Then Exit Sub
        With xCombox
            .Visible = True
            .Left = Target.Left
            .Top = Target.Top
            .Width = Target.Width + 5
            .Height = Target.Height + 5
            .ListFillRange = xStr
            .LinkedCell = Target.Address
        End With
        xCombox.Activate
        Me.Tempcombo.DropDown
      End If
    End If
End Sub

Qui fonctionne bien au demeurant sauf quand je selectionne plusieurs colonnes dont la colonne sur laquelle j’ai des comboboxn j’ai alors une erreur 1024 qui me renvoit a cette ligne :

If Target.Validation.Type = 3 Then

J’imagine bien que le problème vient du fait que vu que dans la selection il y a la colonne contenant la combobox donc de type 3 mais egalement des cellules “normales”.

Quelqu’un saurait comment je peux régler ce problème.

Merci.

Bonjour,

    If Target.Count > 1 Then Exit Sub

Cordialement.

    If Target.Count > 1 Then Exit Sub

A mettre avant ca?

If Target.Validation.Type = 3 Then

C'est bien ca?

A mettre avant oui, c'est bien ca, et ca à l'air de fonctionner! Un grand merci à toi t'es toujours le meilleur

En début de procédure...

Rechercher des sujets similaires à "erreur 1004"