我想寫一個宏代碼,將做如下的單元格區域VBA條件格式細胞值大於或小於
- 條件格式將僅在細胞有申請已輸入值
- 如果單元格中的值小於$ I $ 6和/或大於$ M $ 6,則突出顯示紅色,如果不是,請不要突出顯示(或不應用)。
這是作爲一個規格檢查輸入的數據,以確保數字在規格範圍內。謝謝!
我試了一下:
Sub SpecCheck()
Dim iRow As Range
Set iRow = Range("f16:l34")
For Each cell In iRow
If cell.Value <> "" And cell.Value > "I6" And cell.Value < "M6" Then
cell.Interior.Color = RGB(255, 0, 0)
End If
Next
End Sub
新的代碼我試過了,沒有工作。也不確定是否有問題,但代碼是用工作表的「常規」代碼編寫的。
Sub SpecCheck()
Dim iRow As Range, cell As Range
Dim lowSpec As Range
Dim highSpec As Range
Set iRow = Range("f16:l34")
Set lowSpec = Range("r6")
Set highSpec = Range("s6")
For Each cell In iRow
If cell.Value <> "" And cell.Value > highSpec And cell.Value < lowSpec Then
cell.Interior.Color = RGB(255, 0, 0)
End If
Next
End Sub
**'我想編寫一個宏code' ** ......好了,這是怎麼回事...? SO不是**'「爲我的網站編寫代碼」**。告訴我們你到目前爲止試過的東西以及你卡在哪裏。 – ManishChristian
子SpecCheck() 昏暗iRow作爲範圍設定 = iRow範圍( 「F16:1-34」) 針對每個小區在iRow 如果cell.Value <> 「」 而cell.Value> 「I6」 和細胞。值<「M6」Then cell.Interior.Color = RGB(255,0,0) End If Next End Sub –