Comment faire coexister ses deux codes sur la même feuille?
Bonjour
Tout est dans le titre...
En effet voici les deux codes à compiler :
Private Sub Worksheet_Change(ByVal Target As Range)
Set Target = Intersect(Target, [E2:E65536])
If Target Is Nothing Then Exit Sub
Dim T As String, s As Object, e As Byte
Application.ScreenUpdating = False
ThisWorkbook.DisplayDrawingObjects = xlAll
'---Effacement---
T = Target.Cells(1, 1).Formula
Application.EnableEvents = False
Target.ClearContents
Target.Font.ColorIndex = xlAutomatic
For Each s In ActiveSheet.Shapes
If s.TopLeftCell = "" And s.TopLeftCell.Column = 5 Then s.Delete
Next
Set Target = Target.Cells(1, 1)
Target.Formula = T
Application.EnableEvents = True
'---Création de la forme---
If IsNumeric(Target) Then 'en cas de valeur d'erreur
If Target > 0 And Target <= 9 Then
Target.Font.ColorIndex = 2
With ActiveSheet.Shapes.AddShape(msoShapeRectangle, 0, 0, 100, 15)
.OnAction = "Selectionne"
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
With .TextFrame
e = Int(CDec(Target))
.Characters.Text = Application.Rept("ê", e - (Target > e))
.Characters.Font.Name = "Wingdings 2"
.Characters.Font.ColorIndex = [H4].Offset(Target - e < 0.5).Font.ColorIndex
If e > 0 Then .Characters(1, e).Font.ColorIndex = [H5].Font.ColorIndex
.AutoSize = True
End With
.Left = Target.Left + Application.Max(0, (Target.Width - .Width) / 2)
.Top = Target.Top + Application.Max(0, 1 + (Target.Height - .Height) / 2)
End With
End If
End If
Application.OnRepeat "", ""
End SubPrivate Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
End Sub
With Target
If .Column = 2 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 279.5
.Comment.Shape.Height = 130.75
End If
SendKeys "%im"
End If
End WithCar voici le message d'erreur si les deux sont collés à la suite :
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
précédé d'une flèche...
merci par avance aux connaisseurs.
Bonsoir, PyranaS9, AnthoyS ou AnthoyT, ou autre, on ne sait plus, vu le nombre de pseudos que tu te donnes.....
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
End Sub
With Target
If .Column = 2 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 279.5
.Comment.Shape.Height = 130.75
End If
SendKeys "%im"
End If
End WithEuh, y'a rien qui te choque?
Private Sub .....
End sub...
Et tout le reste derrière....
Mais à force de chercher sur de multiples forums, il est vrai qu'on se perd.....
Bon courage
Oui c'est normal, ta 2è macro est mal délimitée :
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
End Sub
With Target
If .Column = 2 Then
Essaie en mettant le end sub à la fin comme ceci :
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
With Target
If .Column = 2 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 279.5
.Comment.Shape.Height = 130.75
End If
SendKeys "%im"
End If
End With
End Sub