Mettre plusieurs intersect dans la meme feuille

bonjour, je vous explique mon dilemme, dans le gestionnaire de noms, j'ai sélectionné plusieurs cellules sous le nom "rcoche".

quand je clique dessus, avec la macro ci-dessous un X apparait ou disparait par double clic dans les cellules appartenant à "rcoche"

J'ai besoin de la même fonction mais avec un autre groupe de cellules ( par exemple "dcoche") et en cliquant dessus , apparaissant "SFN" ou "MFN"

et ceci sur la même feuille

Est-ce possible , vue que cette fonction "Sub worksheet_BeforeDoubleclick est unique dans chaque feuille

voici ma macro :

Private Sub worksheet_BeforeDoubleclick(ByVal target As Range, cancel As Boolean)

If Intersect(Range("rcoche"), target) Is Nothing Then Exit Sub

If IsEmpty(target) Then

target = "X"

cancel = True

Else

If target = "X" Then

target = ""

cancel = True

End If

End If

End Sub

merci de votre aide

a+ merci

Angus

bonjour,

il faut rajouter des conditions dans la procédure

Private Sub worksheet_BeforeDoubleclick(ByVal target As Range, cancel As Boolean)

If Not (Intersect(Range("rcoche"), target) Is Nothing) Then
If IsEmpty(target) Then
target = "X"
cancel = True
Else
If target = "X" Then
target = ""
cancel = True
End If
End If
Else
 if Not (Intersect(Range("dcoche"), target) Is Nothing) Then
' ce qu'il faut faire dans ce cas ci
else
 exit sub
End If
End Sub

Bonjour,

Une autre approche

Private Sub worksheet_BeforeDoubleclick(ByVal target As Range, cancel As Boolean)
Dim Texte1 As String, Texte2 As String
    If Not Intersect(Range("rcoche"), target) Is Nothing Then
        Texte1 = "X"
        Texte2 = ""
    ElseIf Not Intersect(Range("dcoche"), target) Is Nothing Then
        Texte1 = "SFN"
        Texte2 = "MFN"
    Else
        Exit Sub
    End If
    If IsEmpty(target) Then
        target = Texte1
        cancel = True
    Else
        If target = Texte1 Then
            target = Texte2
            cancel = True
        Else
            target = Texte1
            cancel = True
        End If
    End If
End Sub

A+

merci a vous deux, ca marche tres bien

au plaisir et si je peux aider avec mes maigres connaissances, ce sera avec plaisir

bye

angus

Rechercher des sujets similaires à "mettre intersect meme feuille"