VBA根据表中的ColorIndex为整行着色

时间:2019-08-07 11:40:57

标签: excel vba

我有一个表,其中列EColorIndex组成

我已使用以下代码从Sheet1中的单元格中提取了颜色索引

Function BGCol(ThisCell As Range) As Long
BGCol = ThisCell.Interior.ColorIndex
End Function

并将ColorIndex的值粘贴到Sheet2中。如何根据现在得到的ColorIndex给整个行着色。值为-41421935363843。我在Sheet2中有一个表,其中列EColorIndex值组成。

1 个答案:

答案 0 :(得分:2)

类似的方法将起作用:

ActiveSheet.Rows(2).Interior.ColorIndex = Range("E2").Value

将其循环放置并更改行索引和范围索引。

赞:

With Worksheets("Sheet2")

For i = 1 To 100

     .Rows(i).Interior.ColorIndex = .Range("E" & i).Value

Next

End With
相关问题