![](/img/trans.png)
[英]Excel & VBA: 'If value is less than 1' condition being triggered by a value that is exactly 1
[英]VBA Excel, if value less than
我在C列和D列中将值设置为“常规”格式。无论C列和D列中的单元格值介于0还是9之间,VBA宏如何将格式更改为Number? 基本上我希望0为0.00,9为9.00。
谢谢
试试看:
Sub formatit()
Dim r As Range, N As Long
Set r = Intersect(ActiveSheet.UsedRange, Range("C:D"))
N = Cells(Rows.Count, "C").End(xlUp).Row
For i = 1 To N
cc = Cells(i, "C").Value
dd = Cells(i, "D").Value
If cc >= 0 And cc <= 9 And dd >= 0 And dd <= 9 Then
Range(Cells(i, "C"), Cells(i, "D")).NumberFormat = "0.00"
End If
Next i
End Sub
VBA是否有特定需求? 否则, 条件格式应该可以帮助您实现目标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.