根据公式值格式化单元格 [英] Format cell based on formula value

查看:54
本文介绍了根据公式值格式化单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的单元格数据为 Peer(3)

我用 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.

谢谢

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

推荐答案

也许

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

这篇关于根据公式值格式化单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆