我正在尝试创建一个代码,如果B列的值为“ 7:00”而G列的值为“ 0”,则该行将删除一行。我一直在弄乱下面的代码,除非我输入为“'7:00”,否则代码似乎无法识别B列中的“ 7:00”(格式为h:mm)。这与时间值的格式有关吗?有没有更好的方法可以做到这一点?
我一直在尝试的代码:
Dim N As Long, i As Long
N = Cells(Rows.Count, "B").End(xlUp).Row
For i = N To 1 Step -1
If Cells(i, "B") = "7:00" And Cells(i, "G") = "0" Then
Cells(i, "B").EntireRow.Delete
End If
Next i
这应该为您工作。
If Cells(i, "B").Text = "7:00" And Cells(i, "G").Text = "0" Then
Cells(i, "B").EntireRow.Delete
End If
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句