Conflit dans Macro (Private Sub Worksheet_BeforeDoubleClick(

Résolu

Bonjour à toutes et à tous

J'ai un soucis de conflit .. j'ai deux macro avec le meme nom dans la meme feuille et cela me créé un conflit, et je ne sais pas comment faire pour changer le nom de l'une ou l'autre macro. 
J'ai essayé juste en ajoutant un 1 par exemple mais ca ne fonctionne pas. 
Je vous met le code, j'espère que vous pourrez m'aider. 

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  temp = Array("X", "")
  If Not Application.Intersect(Target, Range("B13:D1000,AF13:BM1000")) Is Nothing Then
    With Target
  p = Application.Match(Target, temp, 0)
  If Not IsError(p) Then
    If p = UBound(temp) + 1 Then p = 0
  Else
    p = 0
  End If
  Target = temp(p)
  Cancel = True
  End With
  End If
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
  On Error GoTo fin
  Application.EnableEvents = False
    If Not Application.Intersect(Target, Range("D10:D" & Rows.Count)) Is Nothing Then
      If Target <> "" Then
        Target.Offset(, -2).Resize(, 2) = "X"
      Else
        Target.Offset(, -2).Resize(, 2).ClearContents
      End If
    End If
fin:
  Application.EnableEvents = True
  
  If Target.Count = 1 And Target.Column = 7 Then
    Select Case Target.Value
      Case "F"
        Cells(Target.Row, 8) = "1"
      Case Else
        Cells(Target.Row, 8) = ""
      End Select
  End If
  
  If Target.Count = 1 And Target.Column = 9 Then 'Numéro de colonne de ma barre de progression
    Select Case Target.Value
      Case "1"
        Cells(Target.Row, 8) = "F"  'Numéro de colonne ou apparaitra le "f"
      
      End Select
  End If
  
End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Application.Intersect(Target, Range("H15:H2000")) Is Nothing Then Exit Sub
    Sheets("Planning").Range("h9").Value = Target.Value
    Cancel = True
End Sub

Merci à tous 

2 réponses

  1. Il ne faut pas retirer ce end if, il termine le cas où

     
    Application.Intersect(Target, Range("B13:D1000,AF13:BM1000")) n'est pas nothing

    si tu le conserves, le cas

     
    If Application.Intersect(Target, Range("H15:H2000")) Is Nothing 

    ne sera jamais examiné

    En fait, c'est le dernier end if qu'il faut supprimer !

    Et comme ça ce sera plus clair

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
      temp = Array("X", "")
      If Not Application.Intersect(Target, Range("B13:D1000,AF13:BM1000")) Is Nothing Then
        With Target
          p = Application.Match(Target, temp, 0)
          If Not IsError(p) Then
            If p = UBound(temp) + 1 Then p = 0
          Else
            p = 0
          End If
          Target = temp(p)
          Cancel = True
        End With
      End If '(Je l'ai retiré)
      If Not Application.Intersect(Target, Range("H15:H2000")) Is Nothing Then
        Sheets("Planning").Range("h9").Value = Target.Value
        Cancel = True
      End If
    End Sub

    Cdlmnt

    1
    1. Parfait. Merci encore BCP 

      0
  2. Bonjour

    Essaies comme ça avec une seule procedure BeforeDoubleClick

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
      temp = Array("X", "")
      If Not Application.Intersect(Target, Range("B13:D1000,AF13:BM1000")) Is Nothing Then
        With Target
          p = Application.Match(Target, temp, 0)
          If Not IsError(p) Then
            If p = UBound(temp) + 1 Then p = 0
          Else
            p = 0
          End If
          Target = temp(p)
          Cancel = True
        End With
      End If
      If Application.Intersect(Target, Range("H15:H2000")) Is Nothing Then Exit Sub
        Sheets("Planning").Range("h9").Value = Target.Value
        Cancel = True
      End If
    End Sub

    Cdlmnt

    0
    1. Bonjour Merci pour ton aide (ENCORE une fois ;) )

      J'ai ce message d'erreur 

      "Erreur de compilation :

      End If sans bloc If"

      0
    2. @nathan01983
      Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        temp = Array("X", "")
        If Not Application.Intersect(Target, Range("B13:D1000,AF13:BM1000")) Is Nothing Then
          With Target
            p = Application.Match(Target, temp, 0)
            If Not IsError(p) Then
              If p = UBound(temp) + 1 Then p = 0
            Else
              p = 0
            End If
            Target = temp(p)
            Cancel = True
          End With
        'End If (Je l'ai retiré)
        If Application.Intersect(Target, Range("H15:H2000")) Is Nothing Then Exit Sub
          Sheets("Planning").Range("h9").Value = Target.Value
          Cancel = True
        End If
      End Sub

      Le double clic (la premiere partie fontionne) mais le copie cellule lui ne fonctionne pas. 

      0