找到一个单元格并覆盖该信息

时间:2014-06-11 16:58:38

标签: excel vba excel-vba return override

所以我与我想要在不同列中更新的信息签订合同......我需要在合同列表中查找此合同,并使用用户输入覆盖特定信息。

我尝试了下面的代码。我可以在列表中找到合同的位置,但是覆盖不起作用。你能帮忙吗?

Sub UpdateChargesMacro3()

    Dim contract As Double
    Dim BR_Reduction As Double
    Dim RIA_Reduction As Double
    Dim TR_Reduction As Double
    Dim PERA_Reduction As Double
    Dim TPA_Reduction As Double
    Dim JHHH_Reduction As Double
    Dim RowCount As Integer

    contract = Sheets("Input").Range("C29").Value
    JHHH_Reduction = Sheets("Input").Range("C36").Value

    Sheets("Final Summary").Select
    With ActiveSheet.Range("C:C")
        Set uRng = .Find(contract, , xlValues, xlWhole, , MatchCase:=False, searchformat:=False)

        If uRng Is Nothing Then
        MsgBox Prompt:="Contract not found!", Buttons:=vbInformation, Title:="OK"
        End If
        Exit Sub

        If Not uRng Is Nothing Then
            uRng.Activate
            RowCount = ActiveCell.Row
            Sheets("Final Summary").Range("DJ" & RowCount).value = JHHH_Reduction

        End If

    End With

End Sub

1 个答案:

答案 0 :(得分:0)

If uRng Is Nothing Then
MsgBox Prompt:="Contract not found!", Buttons:=vbInformation, Title:="OK"
End If
Exit Sub

始终退出宏

在if语句中移出exit

If uRng Is Nothing Then
MsgBox Prompt:="Contract not found!", Buttons:=vbInformation, Title:="OK"
Exit Sub
End If
相关问题