Consulting

Results 1 to 3 of 3

Thread: Change Cell Color on Sheet "Statistic" if value is negative

  1. #1

    Question Change Cell Color on Sheet "Statistic" if value is negative

    Hi all,

    i have sheet calls Statistic and lots of tables on it. I was wondering if someone could help me to write code that will do true all cells on that sheet and if there are any cell value < 0 to change that cell color to red.

    Thanks

  2. #2
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    range("A1").select
    While ActiveCell.Value <> ""
    If ActiveCell.Value < 0 Then
    With ActiveCell.Interior
    .ColorIndex = vbRed
    .Pattern = xlSolid
    End With
    End If

    ActiveCell.Offset(1, 0).Select 'next row
    Wend

  3. #3
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Conditional Formatting will do that without the need for VBA.

Posting Permissions

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