Autres cellules fusionnées

tigla

XLDnaute Nouveau
bonjour
Le code suivant fonctionne correctement lorsque la Target.Address est la cellule A1. Le problème est que cela ne fonctionne pas lorsqu'il y a fusion des cellule A1:H2.
J'ai essayé les trois écritures avec et sans MergeArea, mais rien n'y fait .
une solution ?

VB:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Intersect(Target, Range("A1:H6")) Is Nothing Then Exit Sub
 
 ' If Target.Address = Range("$A$1").MergeArea.Address Then
 ' If Target.Address = Range("$A$1:$H$2").MergeArea.Address Then
  If Target.Address = Range("titre").MergeArea.Address Then  '  Range("A1:H2")nommer "titre"
 
 If Target.Value = Range("K1") Then
MsgBox "CALL COUL"
Else
 If Target = Range("K4") Or Target = "" Then
MsgBox "CALL PACOUL"
MsgBox "CALL PABB"
Else
 If Target = Range("K2") Then
MsgBox "CALL BB"
Else
 If Target = Range("K3") Then
MsgBox "CALL PORTI"
End If
End If
End If
  End If
Else
MsgBox "adress (a1)incorrect"
End If
End Sub
 

Jacky67

XLDnaute Barbatruc
bonjour
Le code suivant fonctionne correctement lorsque la Target.Address est la cellule A1. Le problème est que cela ne fonctionne pas lorsqu'il y a fusion des cellule A1:H2.
J'ai essayé les trois écritures avec et sans MergeArea, mais rien n'y fait .
une solution ?

VB:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Intersect(Target, Range("A1:H6")) Is Nothing Then Exit Sub
 
 ' If Target.Address = Range("$A$1").MergeArea.Address Then
 ' If Target.Address = Range("$A$1:$H$2").MergeArea.Address Then
  If Target.Address = Range("titre").MergeArea.Address Then  '  Range("A1:H2")nommer "titre"
 
 If Target.Value = Range("K1") Then
MsgBox "CALL COUL"
Else
 If Target = Range("K4") Or Target = "" Then
MsgBox "CALL PACOUL"
MsgBox "CALL PABB"
Else
 If Target = Range("K2") Then
MsgBox "CALL BB"
Else
 If Target = Range("K3") Then
MsgBox "CALL PORTI"
End If
End If
End If
  End If
Else
MsgBox "adress (a1)incorrect"
End If
End Sub
Bonjour à tous
Si j'ai bien compris la manœuvre à faire...
Je ferais quelque chose comme ceci
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Target.Address
    Case "$K$1"
        MsgBox "CALL COUL"
    Case "$K$2"
        MsgBox "CALL BB"
    Case "$K$3"
        MsgBox "CALL PORTI"
    Case "$K$4"
        MsgBox "CALL PACOUL"
        MsgBox "CALL PABB"
    Case Else
        MsgBox Target.Address & vbLf & "adresse incorrecte", vbInformation, "Information"
    End Select
End Sub
 

Discussions similaires

Réponses
1
Affichages
205

Statistiques des forums

Discussions
311 726
Messages
2 081 955
Membres
101 852
dernier inscrit
dthi16088