[英]Highlight Row in Red up to certain column if cell contains certain value
如果 J 列中的單元格值包含值 427,我有一個小宏以紅色突出顯示整行。見下文...
Dim lr As Long
lr = Worksheets("owssvr").Cells.Find("*", Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
Dim cell As Range
For Each cell In Range("J2:J" & lr)
If cell.Value = 427 Then
cell.EntireRow.Interior.Color = 255
End If
我想做的是修改宏,使其僅以紅色突出顯示包含數據的行的部分,而不是整行(在此表的情況下,直到列 AF)。 謝謝你。
如果您只想突出顯示列A
和F
之間的行,請嘗試-
Sub Highlight()
Dim lr As Long
lr = Worksheets("owssvr").Cells.Find("*", Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
Dim cel As Range
For Each cel In Range("J2:J" & lr)
If cel.Value = 427 Then
Range("A" & lr & ":F" & lr).Interior.Color = 255
End If
Next
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.