find方法的常见应用

Sub 查找并操作()
    Dim arr
    Set 日期标记单元格 = Cells.Find("出生日期", lookat:=xlWhole, searchorder:=xlRows)
    
    If Not 日期标记单元格 Is Nothing Then
        第一个找到符合内容的地址 = 日期标记单元格.Address
    End If
    
    Do While Not 日期标记单元格 Is Nothing
        Set 日期单元格 = 日期标记单元格.Offset(0, 1)
        arr = Split(日期单元格.Value, "/")
        日期单元格.Value = arr(2) & "年" & arr(1) & "月" & arr(0) & "日"
        
        Set 日期标记单元格 = Cells.Find("出生日期", after:=日期标记单元格)
        If 日期标记单元格.Address = 第一个找到符合内容的地址 Then Exit Do
    Loop
    
End Sub
posted @ 2025-09-05 17:34  python_learn  阅读(8)  评论(0)    收藏  举报