Search code examples
excelvbacolorslistobject

Removing background color in a new table row


When I add a new row to the bottom of a table, the new row has the same background color as the previous row of the table. I want the new row to have no background color.

The research I've done has said that what I'm attempting below should work. It's not working for me.

Sub Transition_Queue_to_Other()

Dim QueueSheet As Worksheet
Set QueueSheet = ThisWorkbook.Worksheets("Project Queue")

Dim TableQueue As ListObject
Set TableQueue = QueueSheet.ListObjects("TableQueue")

Dim TransColumn As Range
Set TransColumn = QueueSheet.Range("TableQueue[Transition]")

Dim Trans_Queue_Row As Range
Dim i As Integer

With TransColumn
    For i = 1 To .Count

        If InStr(1, .Rows(i).Value, "NPD") > 0 Then

            Dim NPDSheet As Worksheet
            Set NPDSheet = ThisWorkbook.Worksheets("NPD")

            Dim TableNPD As ListObject
            Set TableNPD = NPDSheet.ListObjects("TableNPD")

            Set Trans_Queue_Row = TableQueue.DataBodyRange.Rows(i)
            Set Trans_NPD_Row = TableNPD.ListRows.Add.Range

'Everything above here works perfectly.  My problem is with the following.

            Range(Trans_NPD_Row).Select
            Selection.Interior.Color = xlNone

        End if
    Next i

Solution

  • Trans_NPD_Row is a Range. Don't enclose it in a Range call. Also, no need to Select.

    Trans_NPD_Row.Interior.Color = xlNone