excel vba 判断以改变单元格背景色的问题

2024-12-16 23:06:26
推荐回答(4个)
回答1:

提示dim rng as rangefor each rng in range("A1:A100") if rng.value=1 then rng.interior.colorindex=(一个数值,好象是5?记不清了,录个宏吧。也可以用。.color=vbyellow什么的吧,自己琢磨) if rng.value=0 then rng.interior.colorindex=next

回答2:

Sub gb()
Dim i
For i = 1 To 100
If Sheet1.Cells(i, 1) = 1 Then
Sheet1.Cells(i, 1).Interior.ColorIndex = 6
ElseIf Sheet1.Cells(i, 1) = 0 Then
Sheet1.Cells(i, 1).Interior.ColorIndex = 5
End If
Next

End Sub

回答3:

Sub 填色()

Dim rng As Range
For Each rng In Range("A1:A100")
If rng.Value = 1 Then rng.Interior.ColorIndex = 6
If rng.Value = 0 And rng.Value <> "" Then rng.Interior.ColorIndex = 5
Next
End Sub

回答4:

条件格式就好了啊