替换Excel宏424错误,需要对象

问题描述 投票:0回答:1

我正在尝试根据另一列替换单元格内容

我的替换功能抛出了424 error Object Required

Public Sub OTherPN()
    CurrVal = ActiveCell.Value ' Takes the current value of the cell

    While CurrVal <> " " And NextVal <> " " 
        ' Checks for the condition if the next cell down is blank or does it have a command to STOP
        CurrVal = ActiveCell.Value
        MyLD = ActiveCell.Offset(0, 1).Cells
        ActiveCell.Offset(1, 0).Select
        NextVal = ActiveCell.Value


        While NextVal = CurrVal
            ' This is throwing an error     
            MyLD.Replace What:=ActiveCell.Offset(0, 2).Value, Replacement:=ActiveCell.Offset(0, 3).Value, _
            LookAt:=xlPart, MatchCase:=False

            ActiveCell.Offset(1, 0).Select
            NextVal = ActiveCell.Value

        Wend
    Wend
End Sub

谁能告诉我为什么我出错了?

excel vba replace
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.