+ Reply to Thread
Results 1 to 3 of 3

can you make this faster?

  1. #1
    John
    Guest

    can you make this faster?

    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

  2. #2
    Jake Marx
    Guest

    Re: can you make this faster?

    Hi John,

    John wrote:
    > 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]



  3. #3
    baj
    Guest

    Re: can you make this faster?

    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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1