Option Explicit
Sub deleteRows14()
Dim xrow As Long, xcol As Long, rcell As Range
xrow = 1
xcol = 2
Do Until Cells(xrow, xcol).Value = ""
Cells(xrow, xcol).Select
If Cells(xrow, xcol).Value <> "" Then
Selection.FormatConditions.Add Type:=xlTextString, String:="**/**/14", _
TextOperator:=xlContains
With Selection.FormatConditions(1).Font
.Color = RGB(0, 255, 0)
.TintAndShade = 0
End With
If Cells(xrow, xcol).Font.Color = RGB(0, 255, 0) Then
Selection.EntireRow.Delete
End If
End If
xrow = xrow + 1
Loop
嘿伙计们,我正在尝试删除具有特定日期的列中的值。我想出了这个代码,使用条件格式化将某些单元格转换为某种颜色,然后再次循环并删除那些特定颜色的单元格。如果你不能说,我是业余爱好者。
无论如何,第二个If语句&#34; If Cells(xrow,xcol).Font.Color = RGB(0,255,0)然后&#34;不会注册为真;我无法删除任何行。我该如何解决这条问题?
编辑:好的,这是我现在所处的位置,感谢cyboashu的帮助
Option Explicit
Sub deleteRows14()
Dim xrow As Long, xcol As Long, rcell As Range
xrow = 1
xcol = 2
Do Until Cells(xrow, xcol).Value = ""
Cells(xrow, xcol).Select
If Cells(xrow, xcol).Value <> "" Then
Selection.FormatConditions.Add Type:=xlTextString, String:="**/**/14", _
TextOperator:=xlContains
If Application.Evaluate(Selection.FormatConditions(1).Formula1) Then
Selection.EntireRow.Delete
Else: xrow = xrow + 1
End If
End If
Loop
End Sub