Problème avec range

Bonjour,

j'ai ce code qui me met une erreur, effectivement la ligne If Range(x, y) = Range("G9:AT36") Then me fais une erreur?

avec cette ligne j'aimerais que si on ais dans une cellule entre G9 et AT36 le script se réalise sinon pas, voici le code et le fichier join

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Target.Select
x = ActiveCell.Row
y = ActiveCell.Column
If Range(x, y) = Range("G9:AT36") Then
Application.EnableEvents = False
If Not Intersect(Target, Cells(x, y)) Is Nothing Then
       If Now() >= Range("b2") And Now() <= Range("b3") Then
              On Error Resume Next
              If Target.Value = "" Then
                 Target.Selection.ClearComments
                 Range(x, y).Offset(39, 0).Value = ""
              End If
          Cells(x + 39, y) = ActiveCell.Value
          Cells(x, y).AddComment
          Cells(x, y).Comment.Visible = False
          Cells(x, y).Comment.Text Text:="1er semèstre"
               If Target.Value = "" Then
                   Target.ClearComments
               End If
       End If
       If Now() >= Range("b5") And Now() <= Range("b6") Then
             On Error Resume Next
             If Target.Value = "" Then
                Cells(x, y).Selection.ClearComments
                Range(x, y).Offset(66, 0).Value = ""
             End If
          Cells(x + 66, y) = ActiveCell.Value
          Cells(x, y).AddComment
          Cells(x, y).Comment.Visible = False
          Cells(x, y).Comment.Text Text:="2ème semèstre"
               If Target.Value = "" Then
                   Target.ClearComments
               End If
       End If
End If
End If
Target.Select
Application.EnableEvents = True
End Sub

Réponse trois lignes plus bas

If not intersect(cells(x, y) , Range("G9:AT36")) is nothing Then

merci, ca marche, encore une autre question, comment executer le script seulement si on est sur la feuil1 et pas les autres?

merci

Rechercher des sujets similaires à "probleme range"