+ Reply to Thread
Results 1 to 3 of 3

If...Else If

  1. #1
    Registered User
    Join Date
    08-19-2011
    Location
    CA, USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    If...Else If

    I am trying to darken the interior of the cells that contain "O". I have attached the following code to a button to be excuted when clicked but the code is not reading what is in the cells and making the interior of the entire range clear. Why does it not recognize the cells that contain "O" and darken their interior?

    Dim thecell
    Range("C4:K9").Select
    For Each thecell In Selection
    If thecell.Value = "O" Then
    With Selection.Interior
    .ColorIndex = 15
    .Pattern = xlSolid
    End With
    ElseIf thecell.Value <> "O" Then
    With Selection.Interior
    .ColorIndex = xlNone
    End With
    End If
    Next thecell

    End Sub

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: If...Else If

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: If...Else If

    A bit tidier

    Please Login or Register  to view this content.

+ 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