Results 1 to 3 of 3

Thread: How to 'no-fill' empty cell that has been highlighted before?

  1. #1

    How to 'no-fill' empty cell that has been highlighted before?



    Register for a FREE account, and/
    or Log in to avoid these ads!

    i have code like below. This code will highlight the cell if meet condition. But it also highlight empty cell too.
    My problem is to 'no-fill' the highlighted empty cell.
    Below is the code sample



    If processrow > 0 Then

    yearidx = Year(.Cells(i, "B").value) - Application.Min(target.Rows(1))
    monthidx = Month(.Cells(i, "B").value)
    If Application.CountA(target.Rows(processrow)) > 1 Then

    processrow = processrow + 1
    target.Rows(processrow).Insert
    End If

    targetcol = yearidx * 12 + monthidx + 1
    target.Cells(processrow, targetcol).value = .Cells(i, "C").value
    target.Cells(processrow, targetcol).Interior.ColorIndex = 3



    End If

  2. #2
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,356
    Articles
    0
    Excel Version
    365
    change last line above to:
    Code:
    If Len(.Cells(i, "C").Value) > 0 Then target.Cells(processrow, targetcol).Interior.ColorIndex = 3

  3. #3
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,356
    Articles
    0
    Excel Version
    365
    oops, that should have been:
    Code:
    If Len(.Cells(i, "C").Value) > 0 Then
      target.Cells(processrow, targetcol).Interior.ColorIndex = 3
    Else
      target.Cells(processrow, targetcol).Interior.ColorIndex = xlNone
    End If

Tags for this Thread

Posting Permissions

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