Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Nov 2013
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Change Cell Color

    Hello,

    Below codes works fine for me, In Column C if it has a value of '2' then set cell color to Red.

    Code:
    Sub DeleteRows()
    
    Dim ChkRange As Range
    Set ChkRange = Range("C2:C200")
    
    Dim Cell As Range
    
    For Each Cell In ChkRange
        If Cell = "0" Then
            Cell.EntireRow.Delete
        End If
    Next
    Unload UserForm1
    End Sub

  2. #2
    Lounger Lexi's Avatar
    Join Date
    Aug 2013
    Posts
    25
    Thanks
    20
    Thanked 1 Time in 1 Post
    Seems like I would use conditional formatting in this situation using the formula =C2=2 and applying it to Range =$C$2:$C$200


    But I think that changing one line in your code will do the same thing

    Code:
    Sub ChangeColor()
    
    Dim ChkRange As Range
    Set ChkRange = Range("C2:C200")
    
    Dim Cell As Range
    
    For Each Cell In ChkRange
        If Cell = 2 Then
            Cell.Interior.color=vbRed
        End If
    Next
    Unload UserForm1
    End Sub
    Last edited by Lexi; 2015-02-11 at 19:08.

Posting Permissions

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