Results 1 to 3 of 3

highlight/remove highlight of rows conditional on cellvalue

Threaded View

  1. #1
    Forum Contributor timtim89's Avatar
    Join Date
    01-05-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    141

    highlight/remove highlight of rows conditional on cellvalue

    Hey there,

    What I wish to acheive by this macro is that all rows with value in column B being the same as the chosen value from a dropdown list (in d2) are highlightet, when the macro is run. Also, when d2 is empty and the macro is run, I want the (by the macro) previously highlightet rows to go back to normal (not highlightet). Hope that makes sense The code below (not working) shows what I got at this point.
    I also considered making it a Worksheet_Change event instead, but i guessed this would make it more demanding than a sub to run by click on a commandbutton. Is that right?

    Thanks a lot in advance for your help.

    Sub Highlight()
        
        Dim lngRow As Long
        
        Application.ScreenUpdating = False
        lngRow = Range("B4").End(xlDown).Row
        Do While lngRow > 0
            If Range("d2").Value = "" Then
                Rows(lngRow).Interior.Pattern = xlNone
            Else if Cells(lngRow, 2).Value = Range("d2").Value Then
                Rows(lngRow).Interior.ColorIndex = 3
            
            End If
            lngRow = lngRow - 1
        Loop
        Application.ScreenUpdating = True
       
    End Sub
    Attached Files Attached Files

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