can you make this faster?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

here is the code... is there a quicker way to do this?

Private Sub Worksheet_Calculate()
Dim Target As Range
For Each Target In Range("p4:p34")
If Target.Value = True Then
Cells(Target.Row, "G").Resize(1, 24).Interior.ColorIndex = 15
End If
If Target.Value = False Then
Cells(Target.Row, "G").Resize(1, 24).Interior.ColorIndex = xlNone
End If
Next
End Sub
 
Hi John,
here is the code... is there a quicker way to do this?

Private Sub Worksheet_Calculate()
Dim Target As Range
For Each Target In Range("p4:p34")
If Target.Value = True Then
Cells(Target.Row, "G").Resize(1, 24).Interior.ColorIndex = 15
End If
If Target.Value = False Then
Cells(Target.Row, "G").Resize(1, 24).Interior.ColorIndex = xlNone
End If
Next
End Sub

This is the perfect situation for conditional formatting:

http://www.contextures.com/xlCondFormat03.html

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]
 
Rewriting with the same If...Then structure gives me this... didn't
check the working (perhaps the set x... will give problems, just try
it)

Private Sub Worksheet_Calculate()
Dim Target As Range
set x = Cells(Target.Row, "G").Resize(1, 24).Interior.ColorIndex

For Each Target In Range("p4:p34")
If Target.Value = True Then
x = 15
else x = xlNone
End If
Next
End Sub


Bye
Baj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top