[英]Format cell based on formula value
I have cells with data Peer(3)
我有数据
Peer(3)
I get the number with VALUE(LEFT(RIGHT(F2,2)))
我得到
VALUE(LEFT(RIGHT(F2,2)))
的数字VALUE(LEFT(RIGHT(F2,2)))
then I want to give the cell a color I am trying with but not working I get type mismatch, been trying for couple of hours and getting no where. 然后我想给细胞一个我正在尝试的颜色,但不工作我得到类型不匹配,尝试了几个小时,没有得到任何地方。
Thanks 谢谢
Sub Format()
Dim LastRow As Long
Dim WS As Worksheet
Set WS = Sheets("sheet1")
LastRow = WS.range("F" & WS.Rows.Count).End(xlUp).Row
If WS.range("F2:F" & LastRow).Formula = "=Value(Left(Right(F2, 2)))" < 3 Then cell.Interior.ColorIndex = 10
End Sub
Perhaps 也许
Sub Format()
Dim LastRow As Long
Dim WS As Worksheet
dim rCell as range
Set WS = Sheets("sheet1")
LastRow = WS.range("F" & WS.Rows.Count).End(xlUp).Row
for each rcell in WS.range("F2:F" & LastRow).cells
if clng(Left(Right(rcell.value, 2), 1)) < 3 Then rcell.Interior.ColorIndex = 10
next rcell
End Sub
Instead of using VBA, use Conditional Formatting. 而不是使用VBA,使用条件格式。
for eg Say your cells from F1 to F10 contain values such as Peer(2), Peer(3), Peer(1) etc 例如,假设从F1到F10的单元格包含Peer(2),Peer(3),Peer(1)等值
=VALUE(LEFT(RIGHT(F1,2))) < 3
=VALUE(LEFT(RIGHT(F1,2))) < 3
Hope that helps. 希望有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.