想要着色范围A2:P

我想通过macros着色A2:P的颜色范围,但不能着色。 在我的macros之一,我使用下面的代码,但它不与其他工作。 所以有人可以告诉我简单的代码颜色范围A2:P

Sub SelectiveColor2() Dim ws As Worksheet Dim wb As Workbook Dim lastRow As Long lastRow = ws.Range("A" & Rows.Count).End(xlUp).Row Range("A2:E" & lastRow).Interior.color = RGB(204, 255, 255) End Sub 

只需设置 ws

 Sub SelectiveColor2() Dim ws As Worksheet Dim wb As Workbook Dim lastRow As Long Set ws = ActiveSheet lastRow = ws.Range("A" & Rows.Count).End(xlUp).Row Range("A2:E" & lastRow).Interior.Color = RGB(204, 255, 255) End Sub 

你的代码也到E列而不是P列。