根据单元格突出显示行 - Excel VBA - [英] Highlight Row depending on cell - Excel VBA -

查看:84
本文介绍了根据单元格突出显示行 - Excel VBA - 的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


大家好


我需要一些关于此代码的帮助......


我有一张满是数据的表,Col A,B& C充满数据和col D是1或0 ...当我按下按钮时,我需要突出显示红色的所有行(当我按下按钮时(我知道如何创建!)


我不想使用条件格式,因为工作表使用这种方法大幅减速!!


谢谢

尝试这个

Sub Hilite()

Dim lngRow As Long

Application.ScreenUpdating = False
lngRow = Range(" D1")。End(xlDown).Row
Do while lngRow> 0
If Cells(lngRow,4).Value = 0然后
行(lngRow).Interior.ColorIndex = 3'红色
结束如果
lngRow = lngRow - 1
Loop
Application.ScreenUpdating = True

结束子


 

Hi All

I need some help with this code ......

I have a sheet full of data, Col A , B & C full of data  and col D is 1 or 0 ... I need to highlight all rows in red whenever there is a 0 in Col. D when i press a button (that i know how to create !)

I don't want to use conditional format as the sheet slows down drastically using this method !!

Thanks

解决方案

Try this

Sub Hilite()
   
    Dim lngRow As Long
   
    Application.ScreenUpdating = False
    lngRow = Range("D1").End(xlDown).Row
    Do While lngRow > 0
        If Cells(lngRow, 4).Value = 0 Then
            Rows(lngRow).Interior.ColorIndex = 3 ' red
        End If
        lngRow = lngRow - 1
    Loop
    Application.ScreenUpdating = True
  
End Sub


这篇关于根据单元格突出显示行 - Excel VBA - 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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