Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Excel se bloque avec un brin de paille

1 réponse
Avatar
Fredo P
Sur une feuille Xl 97 J'ai le code ci-dessous. Quand, par exemple, je copie
la cellule H3 et je colle sa valeur sur C3 , excel se bloque. Pour
débloquer,il suffit de démarrer en pas à pas le routine "Enab" qui
semblerait ne pas avoir été exécutée.
Ma question est, il y a t'il, dans le code, une erreur ou une mauvaise
programmation ou est ce un bugg connu d'xl97.?

Private Sub Worksheet_Change(ByVal Tz As Excel.Range)
Dim a$, Cl As Byte
On Error GoTo gesterr
Application.ScreenUpdating = False
Application.EnableEvents = False
If Not IsError(Application.Search(".", Cells(4, Tz.Column))) And Cells(2,
Tz.Column) = 0 Then
a = Right(Cells(4, Tz.Column), Len(Cells(4, Tz.Column)) -
Application.Search(".", Cells(4, Tz.Column)))
If Not Range("C4:AB4").Find(a, lookat:=xlWhole) Is Nothing Then
Cl = Range("C4:AB4").Find(a, lookat:=xlWhole).Column
End If
Cells(3, Cl) = Application.Sum(Range(Range(Cells(5, Tz.Column), Cells(30,
Tz.Column)).Address)) + Application.Sum(Range(Range(Cells(5, Cl), Cells(30,
Cl)).Address))
Else
If Not Intersect([C5:AB40], Tz) Is Nothing Then
Cells(3, Tz.Column) = Application.Sum(Range(Range(Cells(5, Tz.Column),
Cells(30, Tz.Column)).Address))
End If
End If
[AC2] = [Sum(C2:AB2-C3:AB3)]
gesterr:
Err.Clear
Enab
End Sub

Private Sub Worksheet_SelectionChange(ByVal Tz As Excel.Range)
If Not Intersect([AC5:AC40], Tz) Is Nothing And Selection.Count = 1 Then
MsgBox "Consommation d'eau/jour" & ActiveCell * [AC2] \ 1000
End If
Enab
End Sub

Public Sub Enab()
Application.EnableEvents = True
End Sub

1 réponse

Avatar
Fredo P
Contrairement à ce que l'on a souvent affirmé: "ça ne sert à rien de mettre
Application.ScreenUpdating à TRUE ,c'est cette commande qui résoud le pb.

"Fredo P" a écrit dans le message de
news:
Sur une feuille Xl 97 J'ai le code ci-dessous. Quand, par exemple, je
copie

la cellule H3 et je colle sa valeur sur C3 , excel se bloque. Pour
débloquer,il suffit de démarrer en pas à pas le routine "Enab" qui
semblerait ne pas avoir été exécutée.
Ma question est, il y a t'il, dans le code, une erreur ou une mauvaise
programmation ou est ce un bugg connu d'xl97.?

Private Sub Worksheet_Change(ByVal Tz As Excel.Range)
Dim a$, Cl As Byte
On Error GoTo gesterr
Application.ScreenUpdating = False
Application.EnableEvents = False
If Not IsError(Application.Search(".", Cells(4, Tz.Column))) And Cells(2,
Tz.Column) = 0 Then
a = Right(Cells(4, Tz.Column), Len(Cells(4, Tz.Column)) -
Application.Search(".", Cells(4, Tz.Column)))
If Not Range("C4:AB4").Find(a, lookat:=xlWhole) Is Nothing Then
Cl = Range("C4:AB4").Find(a, lookat:=xlWhole).Column
End If
Cells(3, Cl) = Application.Sum(Range(Range(Cells(5, Tz.Column), Cells(30,
Tz.Column)).Address)) + Application.Sum(Range(Range(Cells(5, Cl),
Cells(30,

Cl)).Address))
Else
If Not Intersect([C5:AB40], Tz) Is Nothing Then
Cells(3, Tz.Column) = Application.Sum(Range(Range(Cells(5, Tz.Column),
Cells(30, Tz.Column)).Address))
End If
End If
[AC2] = [Sum(C2:AB2-C3:AB3)]
gesterr:
Err.Clear
Enab
End Sub

Private Sub Worksheet_SelectionChange(ByVal Tz As Excel.Range)
If Not Intersect([AC5:AC40], Tz) Is Nothing And Selection.Count = 1 Then
MsgBox "Consommation d'eau/jour" & ActiveCell * [AC2] 1000
End If
Enab
End Sub

Public Sub Enab()
Application.EnableEvents = True
End Sub