SpectreHUN
New Member
- Joined
- Aug 15, 2014
- Messages
- 14
So my problem is that I have 900 lines of code in a Worksheet Change event sub. On my rig, it runs pretty quickly, but on the PC the sheet will be used on, it takes about 2 seconds to run, so from a productivity standpoint, it's not ideal.
What the sub does is it colorcodes the rows based on whether the item has been paid for or not.
I'm pretty new to VBA, so I could only hardcode it, that's why it is so long. What i'm looking for is a way for the sub to be dynamic.
Here is an excerpt of the code for two lines:
Any help would be appreciated!
What the sub does is it colorcodes the rows based on whether the item has been paid for or not.
I'm pretty new to VBA, so I could only hardcode it, that's why it is so long. What i'm looking for is a way for the sub to be dynamic.
Here is an excerpt of the code for two lines:
Code:
If Not ActiveSheet.Range("B10").Value = "" And Not ActiveSheet.Range("J10").Value = "" Then
ActiveSheet.Unprotect
Rows(10).Interior.Color = RGB(61, 240, 115)
ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
ElseIf Not ActiveSheet.Range("B10").Value = "" And ActiveSheet.Range("J10").Value = "" Then
ActiveSheet.Unprotect
Rows(10).Interior.Color = RGB(240, 61, 79)
ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
Else
ActiveSheet.Unprotect
Rows(10).Interior.ColorIndex = xlNone
ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
If Not ActiveSheet.Range("B13").Value = "" And Not ActiveSheet.Range("J13").Value = "" Then
ActiveSheet.Unprotect
Rows(13).Interior.Color = RGB(61, 240, 115)
ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
ElseIf Not ActiveSheet.Range("B13").Value = "" And ActiveSheet.Range("J13").Value = "" Then
ActiveSheet.Unprotect
Rows(13).Interior.Color = RGB(240, 61, 79)
ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
Else
ActiveSheet.Unprotect
Rows(13).Interior.ColorIndex = xlNone
ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
Any help would be appreciated!