基于像元值的彩色整行 [英] Color Entire Row Based on Cell Value

查看:61
本文介绍了基于像元值的彩色整行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果该行中的两个单元格具有相同的值,我将为整个行着色.

I'm trying to color an entire row if two cells in that row have the same value.

For i = 2 To LastRow
    If Worksheets("Request Results").Cells(i, 4).Value <> Worksheets("Request Results").Cells(i, 6).Value Then
        Cells(i, 1).EnitreRow.Interior.ColorIndex = 255
    ElseIf Worksheets("Request Results").Cells(i, 4).Value = Worksheets("Request Results").Cells(i, 6).Value Then
        Cells(i, 1).EntireRow.Interior.ColorIndex = 5296274
    End If
Next i

循环首先进入else语句,然后我得到

The loop goes into the else statement first and I get

下标超出范围"

"Subscript out of range"

Cells(i, 1).EntireRow.Interior.ColorIndex = 5296274

推荐答案

将ColorIndex更改为Color.

change ColorIndex to Color.

Cells(i, 1).EntireRow.Interior.Color = 5296274

这篇关于基于像元值的彩色整行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆