Compilation de VBA

Bonjour à toutes et à tous.

J'ai deux vba qui fonctionne bien dans deux classeur différents mais quand je veux les mettre dans le même classeur, elle ne marche plus. Merci pour votre aide

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

If Not Intersect(Target, Range("I4:AE4,I14:AE14")) Is Nothing Then

With Target.Interior

If .Pattern = xlUp Then

.Pattern = xlNone

Else

.PatternColorIndex = 44

.Pattern = xlUp

End If

End With

End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

If Not Application.Intersect(Target, Range("J6:L6")) Is Nothing Then

With Target

If Selection.Interior.ColorIndex = 48 Then

Selection.Interior.ColorIndex = xlNone

Else

Selection.Interior.ColorIndex = 48

End If

End With

End If

End Sub

Bonjour

A essayer

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
  If Target.Count > 1 Then Exit Sub
  If Not Intersect(Target, Range("I4:AE4,I14:AE14")) Is Nothing Then
    With Target.Interior
      If .Pattern = xlUp Then
        .Pattern = xlNone
      Else
        .PatternColorIndex = 44
        .Pattern = xlUp
      End If
    End With
  ElseIf Not Application.Intersect(Target, Range("J6:L6")) Is Nothing Then
    With Target
      If .Interior.ColorIndex = 48 Then
        .Interior.ColorIndex = xlNone
      Else
        .Interior.ColorIndex = 48
      End If
    End With
  End If
End Sub
Rechercher des sujets similaires à "compilation vba"