我如何使用.EntireRow,但跳过列A?

寻找一个解决方法或者关于如何使用下面的代码摘录的一些想法,但是跳过A列。

基本上,我正在使用

.EntireRow(a.Row).Interior.Color = color 

突出显示基于用户表单select行,但我需要跳过列A,因为它有自己的突出显示标题。

有任何想法吗?

 If ToggleButton3.Value = True Then On Error Resume Next For iRow = 1 To 15 If Sheets("Prop" & iRow).Visible <> xlSheetVisible Then Else With Sheets("Prop" & iRow).Range("$E$1:$E$157") Set a = .Find(SlctdPAX, LookIn:=xlValues, LookAt:=xlWhole) .EntireRow(a.Row).Interior.Color = RGB(255, 255, 102) 'yellow End With End If Next iRow ElseIf ToggleButton1.Value = True Then On Error Resume Next For iRow = 1 To 15 If Sheets("Prop" & iRow).Visible <> xlSheetVisible Then Else With Sheets("Prop" & iRow).Range("$E$1:$E$157") Set a = .Find(SlctdPAX, LookIn:=xlValues, LookAt:=xlWhole) .EntireRow(a.Row).Interior.Color = RGB(255, 0, 0) 'red End With End If Next iRow ElseIf ToggleButton4.Value = True Then On Error Resume Next For iRow = 1 To 15 If Sheets("Prop" & iRow).Visible <> xlSheetVisible Then Else With Sheets("Prop" & iRow).Range("$E$1:$E$157") Set a = .Find(SlctdPAX, LookIn:=xlValues, LookAt:=xlWhole) .EntireRow(a.Row).Interior.Color = xlNone 'no fill End With End If Next iRow ElseIf ToggleButton2.Value = True Then On Error Resume Next For iRow = 1 To 15 If Sheets("Prop" & iRow).Visible <> xlSheetVisible Then Else With Sheets("Prop" & iRow).Range("$E$1:$E$157") Set a = .Find(SlctdPAX, LookIn:=xlValues, LookAt:=xlWhole) .EntireRow(a.Row).Interior.Color = RGB(128, 255, 0) 'green End With End If Next iRow Else End If 

让我们说a是一个单细胞。

关于排除突出显示列A,

  • 要突出整行的a ,做:

    a.EntireRow.Resize(, Columns.Count - 1).Offset(, 1).Interior.Color

  • 突出显示多行放在一起,例如5行,做:

    a.EntireRow.Resize(5, Columns.Count - 1).Offset(, 1).Interior.Color

  • 为了突出显示多行没有放在一起的行,例如[E1],[E3],[E5]的整行,执行:

    Intersect(Union([E1], [E3], [E5]).EntireRow, Cells.Resize(, Columns.Count - 1).Offset(, 1))

仅供参考,只testing了Union([E1], [E3], [E5]).EntireRow.Resize()是不允许的。

希望这可以帮助。

  With ThisWorkbook.Sheets("Prop" & iRow) Set a = .Range("$E$1:$E$157").Find(SlctdPAX, LookIn:=xlValues, LookAt:=xlWhole) a.EntireRow.Resize(1, .Cells(a.row, .Columns.Count - 1).column).Offset(, 1).Interior.Color = RGB(255, 0, 0) 'red End With 

KS Sheon已经发布了相当多的版本。

但是恐怕他的代码被放置With Sheets("Prop" & iRow).Range("$E$1:$E$157")块中,会将所有行的颜色从1到157。

此外, Columns.Count将计算活动工作表的列数,这可能不是所需的