+ Reply to Thread
Results 1 to 5 of 5

Highlighting Rows Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    05-31-2012
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Highlighting Rows Macro

    I understand that but what I am trying to do is highlight the next row. Say I hax an x in row 5, then row 6 will be highlighted. Then when I put an x in row 6 I want row 6 to no longer be highlighted and then row 7 to highlight. I created the event I just need to fix the actual macro. It is as follows (don't know if the firstAddress part does anything):
    Event:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("F4:F200")) Is Nothing Then
    Call autoHighlight
    End If
    End Sub
    Macro:
    Sub autoHighlight()
    Dim rg As Range, c As Range
      Dim firstAddress As String
        Set rg = Range("F4", "F250")
        Application.ScreenUpdating = False
    With rg
        Set c = .Find("x", lookat:=xlWhole, LookIn:=xlValues)
        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                c.EntireRow.Interior.ColorIndex = 6
                Set c = .FindNext(c)
                If c Is Nothing Then Exit Do
            Loop While c.Address <> firstAddress
        End If
    Application.ScreenUpdating = True
    End With
    End Sub
    Last edited by Paul; 05-31-2012 at 04:07 PM. Reason: Added CODE tags for new user. Please do so yourself in the future.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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