VBA 检查单元格中的文本,内容不为空,背景变白色,为空背景变红

'检查单元格中的文本,内容不为空,背景变白色,为空背景变红
`Sub GetColumnBText()
Dim text As String
Dim target As String

Dim i, j As Integer
Dim position As Integer

Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("sheet1") '修改为实际的工作表名称
target = ""

For i = 6 To 326
For j = 7 To 53
text = ws.Cells(i, j).Value
position = 0

position = InStr(text, target)
If position > 0 Then
ws.Cells(i, j).Interior.ColorIndex = 2

Else
ws.Cells(i, j).Interior.Color = vbRed
MsgBox "i:" & i & ",j:" & j
End If
Next
Next
MsgBox "完了"
End Sub
`

posted on 2024-08-31 14:36  yffs168169  阅读(111)  评论(0)    收藏  举报

导航