删除新表行中的背景色

时间:2019-07-15 01:54:56

标签: excel vba colors listobject

当我在表的底部添加新行时,新行的背景颜色与表的上一行相同。我希望新行没有背景色。

我所做的研究表明,我在下面尝试的应该可行。它对我不起作用。

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

1 个答案:

答案 0 :(得分:2)

<span class="glyphicon glyphicon-ok-circle"></span> Trans_NPD_Row。不要将其包含在Range调用中。另外,无需Range

Select