I have cells with data Peer(3)
I get the number with 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.
for eg Say your cells from F1 to F10 contain values such as Peer(2), Peer(3), Peer(1) etc
=VALUE(LEFT(RIGHT(F1,2))) < 3
Hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.