Autres cellules fusionnées

  • Initiateur de la discussion Initiateur de la discussion tigla
  • 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 !

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
 
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
 
- 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

Réponses
9
Affichages
404
Réponses
14
Affichages
331
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
1 K
Réponses
4
Affichages
406
Retour