#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Slow code

I have the following fairly simple code which runs fairly slowly, could it
be because I have a lot of Conditional Formatting going on at the same time?
and if so , would I be better incorporating the conditional formatting into
my code to acheive better processing?

Sandy

Private Sub Worksheet_Change(ByVal Target As Range)

Sheets("Data Input").Unprotect Password:=""

Application.ScreenUpdating = False
Application.EnableEvents = False

For Each mycell In Range("C9:K9,M9:U9")
If mycell.Value = 3 Then
With mycell.Offset(5)
.Value = "Good"
.Validation.Delete
End With
ElseIf mycell.Value < 3 And mycell.Offset(5).Value = "Good" Then
With mycell.Offset(5)
.Value = "Hit"
With .Validation
.Delete
.Add Type:=xlValidateList,
Formula1:="Left,Right,Short,Long"
.IgnoreBlank = True
.InCellDropdown = True
End With
End With
ElseIf mycell.Value = "" Then
With mycell.Offset(5)
.Value = "Hit"
With .Validation
.Delete
.Add Type:=xlValidateList,
Formula1:="Left,Right,Short,Long"
.IgnoreBlank = True
.InCellDropdown = True
End With
End With
End If
Next

'MsgBox "Hi"

Application.EnableEvents = True
Application.ScreenUpdating = True

Sheets("Data Input").Protect Password:=""

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Slow code

Sandy

It would appear as if this is the case - conditional formatting slowing
down the code.I tried it on my pc and it ran at normal speed.

As you susgessted, try coding the conditional format into VBA and see if
that enhances the speed of the application.

Also I answered your previous query in relation to running VBA code -
conditional formatting update - on the hour (please refer to the previous
thread for the solution).

Regards

SysAccountant

"Sandy" wrote:

I have the following fairly simple code which runs fairly slowly, could it
be because I have a lot of Conditional Formatting going on at the same time?
and if so , would I be better incorporating the conditional formatting into
my code to acheive better processing?

Sandy

Private Sub Worksheet_Change(ByVal Target As Range)

Sheets("Data Input").Unprotect Password:=""

Application.ScreenUpdating = False
Application.EnableEvents = False

For Each mycell In Range("C9:K9,M9:U9")
If mycell.Value = 3 Then
With mycell.Offset(5)
.Value = "Good"
.Validation.Delete
End With
ElseIf mycell.Value < 3 And mycell.Offset(5).Value = "Good" Then
With mycell.Offset(5)
.Value = "Hit"
With .Validation
.Delete
.Add Type:=xlValidateList,
Formula1:="Left,Right,Short,Long"
.IgnoreBlank = True
.InCellDropdown = True
End With
End With
ElseIf mycell.Value = "" Then
With mycell.Offset(5)
.Value = "Hit"
With .Validation
.Delete
.Add Type:=xlValidateList,
Formula1:="Left,Right,Short,Long"
.IgnoreBlank = True
.InCellDropdown = True
End With
End With
End If
Next

'MsgBox "Hi"

Application.EnableEvents = True
Application.ScreenUpdating = True

Sheets("Data Input").Protect Password:=""

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Slow code

Thanks I think I'll do as you suggest and incorporate the conditional
formatting in code. I'll let you know here how it goes.
The other post is for a different Sandy - must be a common Scottish name
after all :)
Sandy

"SysAccountant" wrote in message
...
Sandy

It would appear as if this is the case - conditional formatting slowing
down the code.I tried it on my pc and it ran at normal speed.

As you susgessted, try coding the conditional format into VBA and see if
that enhances the speed of the application.

Also I answered your previous query in relation to running VBA code -
conditional formatting update - on the hour (please refer to the previous
thread for the solution).

Regards

SysAccountant

"Sandy" wrote:

I have the following fairly simple code which runs fairly slowly, could
it
be because I have a lot of Conditional Formatting going on at the same
time?
and if so , would I be better incorporating the conditional formatting
into
my code to acheive better processing?

Sandy

Private Sub Worksheet_Change(ByVal Target As Range)

Sheets("Data Input").Unprotect Password:=""

Application.ScreenUpdating = False
Application.EnableEvents = False

For Each mycell In Range("C9:K9,M9:U9")
If mycell.Value = 3 Then
With mycell.Offset(5)
.Value = "Good"
.Validation.Delete
End With
ElseIf mycell.Value < 3 And mycell.Offset(5).Value = "Good" Then
With mycell.Offset(5)
.Value = "Hit"
With .Validation
.Delete
.Add Type:=xlValidateList,
Formula1:="Left,Right,Short,Long"
.IgnoreBlank = True
.InCellDropdown = True
End With
End With
ElseIf mycell.Value = "" Then
With mycell.Offset(5)
.Value = "Hit"
With .Validation
.Delete
.Add Type:=xlValidateList,
Formula1:="Left,Right,Short,Long"
.IgnoreBlank = True
.InCellDropdown = True
End With
End With
End If
Next

'MsgBox "Hi"

Application.EnableEvents = True
Application.ScreenUpdating = True

Sheets("Data Input").Protect Password:=""

End Sub





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


Similar Threads
Thread Thread Starter Forum Replies Last Post
very slow code andy62 Excel Programming 4 August 2nd 07 03:54 AM
Slow code when used as VBA code instead of macro (copying visible columns) [email protected] Excel Programming 3 April 2nd 07 05:26 PM
SLOW Code... Ernst Guckel[_4_] Excel Programming 2 March 20th 05 10:58 AM
Slow Code Frank Kabel Excel Programming 1 July 23rd 04 09:28 AM
Is this slow code? Tom Excel Programming 4 March 3rd 04 11:18 PM


All times are GMT +1. The time now is 10:34 AM.

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"