#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default worksheet_calculate

Your changes in the code could even be forcing more calculates which might
explain the long time to run. I agree with RichardSchollar that choosing
another event such as Change might be more effective.
If you do that, change things a little to make your code look like this
Application.ScreenUpdating=False
Application.EnableEvents=False
....your functional code here
Application.EnableEvents=True
Application.ScreenUpdating=True


Or, you could perhaps do away with the VBA completely?
In E5, for example:
=IF(H50,IF(I50,900,450),IF(I50,450,""))
just fill that down through E6 and E7 and I believe you'll get the same
results that your code is providing.

"enyaw" wrote:

I have the following code which updates a cell once a value is entered into
one of the others.

Private Sub worksheet_calculate()
Application.ScreenUpdating = False

If Range("H5") And Range("I5") 0 Then
Range("E5") = "900"
ElseIf Range("H5") Or Range("I5") 0 Then
Range("E5") = "450"
Else
Range("E5") = ""
End If

If Range("H6") And Range("I6") 0 Then
Range("E6") = "900"
ElseIf Range("H6") Or Range("I6") 0 Then
Range("E6") = "450"
Else
Range("E6") = ""
End If

If Range("H7") And Range("I7") 0 Then
Range("E7") = "900"
ElseIf Range("H7") Or Range("I7") 0 Then
Range("E7") = "450"
Else
Range("E7") = ""
End If

Application.ScreenUpdating = True

End Sub

The problem is it takes a long time for the code to run. Can anyone help?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"