VBA 找负数求助

s
songshu
楼主 (北美华人网)
需要在一个tab 的一个range里,看有没有负数,如果有就把tab highlight出来,红的绿的都行, If cell.Value < 0 Then 出错, 有mm知道应该怎么写吗?谢谢
 Dim rng As Range  Set rng = Range("F5:H394")  For Each cell In rng  If cell.Value < 0 Then
 With ActiveWorkbook.Sheets("i").Tab     .Color = 255     .TintAndShade = 0   End With End If
h
huashan2018
你得把错误也贴出来。
m
mallowmarsh
,是error 9吗
0
0526arap
Sub test()
Dim rng As Range
 Set rng = ActiveSheet.Range("A1:H100")
 For Each cell In rng
 If cell.Value < 0 Then
 cell.Interior.Color = 255
End If  Next cell End Sub

你可以根据情况改改 好像你写的最主要的问题是 loop 没有用next 结尾 然后 color 是interior的property