Modification code

Bonjour je souhaiterai modifier ce code:

With Feuil3
  Set plage = .Range("E5,C5,C8,C12,C15,C37,G19,G21,G23,G25,G27,G29,G31,G33")

    For Each cel In plage
        If cel = vbNullString Then
            MsgBox "Veuillez compléter la rubrique " & vbCrLf & vbCrLf & _
                cel.Offset(-1, 0) & " - cellule " & cel.Address, vbInformation, "Information manquante"
            Exit Sub
        End If

En : si dans la cellule E49 j'ai le texte XXXX j'applique

With Feuil3
  Set plage = .Range("E5,C5,C8,C12,C15,C37,G19,G21,G23,G25,G27")

    For Each cel In plage
        If cel = vbNullString Then
            MsgBox "Veuillez compléter la rubrique " & vbCrLf & vbCrLf & _
                cel.Offset(-1, 0) & " - cellule " & cel.Address, vbInformation, "Information manquante"
            Exit Sub
        End If

et si E49 différent de XXXX j'applique le code de base.

Je pense que c'est tous bête mais mes connaissances sont très limités

Merci de votre aide

Bonjour,

Si il n'y a que la plage qui bouge, on peut rajouter un petit bloc "If" (= SI) comme ceci

  With Feuil3
    If .Range("E49").Value2 = "XXXX" Then
      Set plage = .Range("E5,C5,C8,C12,C15,C37,G19,G21,G23,G25,G27")
    Else
      Set plage = .Range("E5,C5,C8,C12,C15,C37,G19,G21,G23,G25,G27,G29,G31,G33")
    End If

    For Each cel In plage
      If cel = vbNullString Then
        MsgBox "Veuillez compléter la rubrique " & vbCrLf & vbCrLf & _
               cel.Offset(-1, 0) & " - cellule " & cel.Address, vbInformation, "Information manquante"
        Exit Sub
      End If
    Next cel
  End With

Nickel je te remercie

Rechercher des sujets similaires à "modification code"