On Error Resume Next If Target.Count > 1 Then Exit Sub
AEE = Application.EnableEvents ASU = Application.ScreenUpdating If Not Intersect(Target.Cells, rZved) Is Nothing Then
AEE = False ASU = False
If LRh > 6 Then Range("A5:L" & LRh).Sort Key1:=[h6], Order1:=xlAscending, _ Header:=xlGuess, Orientation:=xlTopToBottom End If SumS = "=SUBTOTAL(9, R5C:R[-1]C)" 'And SumP = "=SUBTOTAL(9, R5C:R[-1]C)"
If Cells(6, 11) > 0 Then Else Cells(6, 11) = 1 End If
If LRh > 6 Then For x = 7 To LRh If Cells(x, 8) > Cells(x - 1, 8) And Cells(x, 8) > 0 Then Cells(x, 11) = Cells(x - 1, 11) + 1 ElseIf Cells(x, 8) = Cells(x - 1, 8) And Cells(x, 8) > 0 Then Cells(x, 11) = Cells(x - 1, 11) End If Next x End If
Cells(LR2, 4) = SumS Cells(LR2, 5) = SumP
ASU = True AEE = True
End If End Sub
[/vba]
Почему выполнив строчку Cells(LR2, 4) = SumS код начинается заново. Как это предотвратить? П.С. Заголовки в строке 5 П.С.2: Cells(LR2, 4).formular1c1 = SumS не помогло
On Error Resume Next If Target.Count > 1 Then Exit Sub
AEE = Application.EnableEvents ASU = Application.ScreenUpdating If Not Intersect(Target.Cells, rZved) Is Nothing Then
AEE = False ASU = False
If LRh > 6 Then Range("A5:L" & LRh).Sort Key1:=[h6], Order1:=xlAscending, _ Header:=xlGuess, Orientation:=xlTopToBottom End If SumS = "=SUBTOTAL(9, R5C:R[-1]C)" 'And SumP = "=SUBTOTAL(9, R5C:R[-1]C)"
If Cells(6, 11) > 0 Then Else Cells(6, 11) = 1 End If
If LRh > 6 Then For x = 7 To LRh If Cells(x, 8) > Cells(x - 1, 8) And Cells(x, 8) > 0 Then Cells(x, 11) = Cells(x - 1, 11) + 1 ElseIf Cells(x, 8) = Cells(x - 1, 8) And Cells(x, 8) > 0 Then Cells(x, 11) = Cells(x - 1, 11) End If Next x End If
Cells(LR2, 4) = SumS Cells(LR2, 5) = SumP
ASU = True AEE = True
End If End Sub
[/vba]
Почему выполнив строчку Cells(LR2, 4) = SumS код начинается заново. Как это предотвратить? П.С. Заголовки в строке 5 П.С.2: Cells(LR2, 4).formular1c1 = SumS не помоглоbygaga
Сообщение отредактировал bygaga - Вторник, 17.02.2015, 14:58
AEE = Application.EnableEvents у вас только присваивает значение True переменной AEE, можете по Locals глянуть. А потом этой переменной вы присваиваете AEE = False, потом AEE = True. Отключение\включение событий здесь ни при чем.
AEE = Application.EnableEvents у вас только присваивает значение True переменной AEE, можете по Locals глянуть. А потом этой переменной вы присваиваете AEE = False, потом AEE = True. Отключение\включение событий здесь ни при чем.Leanna
Лучше день потерять, потом за пять минут долететь!
On Error Resume Next If Target.Count > 1 Then Exit Sub
If Not Intersect(Target.Cells, rZved) Is Nothing Then
If LRh > 6 Then Range("A5:L" & LRh).Sort Key1:=[h6], Order1:=xlAscending, _ Header:=xlGuess, Orientation:=xlTopToBottom End If SumS = "=SUBTOTAL(9, R5C:R[-1]C)" 'And SumP = "=SUBTOTAL(9, R5C:R[-1]C)"
If Cells(6, 11) > 0 Then Else Cells(6, 11) = 1 End If
If LRh > 6 Then For x = 7 To LRh If Cells(x, 8) > Cells(x - 1, 8) And Cells(x, 8) > 0 Then Cells(x, 11) = Cells(x - 1, 11) + 1 ElseIf Cells(x, 8) = Cells(x - 1, 8) And Cells(x, 8) > 0 Then Cells(x, 11) = Cells(x - 1, 11) End If Next x End If
Cells(LR2, 4) = SumS Cells(LR2, 5) = SumP
End If Application.EnableEvents = True Application.ScreenUpdating = True End Sub
[/vba]
Leanna, оу... я даже не увидел этого прикола с переменной)))
On Error Resume Next If Target.Count > 1 Then Exit Sub
If Not Intersect(Target.Cells, rZved) Is Nothing Then
If LRh > 6 Then Range("A5:L" & LRh).Sort Key1:=[h6], Order1:=xlAscending, _ Header:=xlGuess, Orientation:=xlTopToBottom End If SumS = "=SUBTOTAL(9, R5C:R[-1]C)" 'And SumP = "=SUBTOTAL(9, R5C:R[-1]C)"
If Cells(6, 11) > 0 Then Else Cells(6, 11) = 1 End If
If LRh > 6 Then For x = 7 To LRh If Cells(x, 8) > Cells(x - 1, 8) And Cells(x, 8) > 0 Then Cells(x, 11) = Cells(x - 1, 11) + 1 ElseIf Cells(x, 8) = Cells(x - 1, 8) And Cells(x, 8) > 0 Then Cells(x, 11) = Cells(x - 1, 11) End If Next x End If
Cells(LR2, 4) = SumS Cells(LR2, 5) = SumP
End If Application.EnableEvents = True Application.ScreenUpdating = True End Sub