Sub test
Dim s As Long
Dim lr As Long
s=11
lr = Cells(Rows.Count, 3).End(xlUp).row
Do Until s>lr
If Cells(s,5).Value < 0 Then
Cells(s,5).style = “comma”
lr = lr -1
Else
s = s + 1
End If
Loop
End sub
此代码旨在更改它找到的第一个零值,然后它将停止。这些值在 E 列中,需要更改其样式,但我无法弄清楚。
最佳答案
那是因为如果值小于 0 则 s
永远不会增加。另外,不确定为什么要递减 lr
?将增量代码移到 if... then
之外声明,它应该工作。
Do Until s>lr
If Cells(s,5).Value < 0 Then
Cells(s,5).style = “comma”
End If
s = s + 1
Loop
关于excel - 尝试将值小于零的单元格格式化为逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57975840/