以下是用VBA编写的代码:

Sub CheckCells()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim currentDate As Date
    Dim cell As Range
    
    Set ws = ThisWorkbook.Sheets("2023年汇总") '更改为实际的表格名称
    lastRow = ws.Cells(ws.Rows.Count, "AE").End(xlUp).Row
    currentDate = Date
    
    For Each cell In ws.Range("AE2:AE" & lastRow)
        If cell.Value = "抵押" And cell.Offset(0, 22).Value <> "" And cell.Offset(0, -1).Value = "" Then
            If cell.Offset(0, 22).Value - currentDate < 20 Then
                cell.Offset(0, 22).Select
                MsgBox "日期小于20天"
            End If
        End If
    Next cell
End Sub

请将代码中的"2023年汇总"替换为实际的表格名称。代码将遍历列AE中的每个单元格,如果满足条件(列AE为"抵押",列X不是空值,列AD为空),则比较列X的日期与当前日期,如果小于20天,则跳转到该单元格并显示提示信息


原文地址: http://www.cveoy.top/t/topic/iWw0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录