Problème de cellules fusionnées

Bonsoir,

j'ai un code (de eriiic) qui me permet de détecter sur une certaine plage les cellules suivantes :

  • Ne contient pas comme couleur de fond le rouge
  • Ne contient aucune valeur

Le problème c'est que ça ne fonctionne que si les cellules ne sont pas fusionnées, quelqu'un aurait la solution SVP?

Sub test()

Dim Plg As Range
Set Plg = Range("B4:H5,B10:H10,B16:H16,B22:H22")

    Dim Cel As Range, pl As Range
    For Each Cel In Plg
        If Not Cel.Interior.Color = 255 And Cel.value = "" Then
            If pl Is Nothing Then Set pl = Cel Else Set pl = Union(pl, Cel)
        End If
    Next Cel
    pl.Select
End Sub

Merci bien!

Bonjour TNRX,

Voir le code ci-dessous:

Sub testA()
Dim Plg As Range, Inter As Range, deja As Range, Cel As Range, pl As Range

   Set Plg = Range("B4:H5,B10:H10,B16:H16,B22:H22")
   For Each Cel In Plg
      If deja Is Nothing Then Set Inter = Nothing Else Set Inter = Intersect(deja, Cel)
      If Inter Is Nothing Then
         If Not Cel.Interior.Color = 255 And Cel.Value = "" Then
            If pl Is Nothing Then Set pl = Cel.MergeArea Else Set pl = Union(pl, Cel.MergeArea)
         End If
      End If
      If deja Is Nothing Then Set deja = Cel.MergeArea Else Set deja = Union(deja, Cel.MergeArea)
   Next Cel
   Range("a1").Select
   If Not pl Is Nothing Then pl.Select
   If Not pl Is Nothing Then MsgBox pl.Address(0, 0)       'pour le test uniquement
End Sub

Bonjour MaPoire,

Merci pour la réponse rapide et pour le code.

Tout marche parfaitement bien!

A+

Rechercher des sujets similaires à "probleme fusionnees"