按下运行时VBA宏不运行

时间:2017-05-30 14:12:32

标签: excel vba excel-vba

Sub Button2_Click()
    Dim R As Range
    Dim C As Range
    Dim Msg As String

    With Sheets("data").Range("A1").CurrentRegion
        For Each R In Sheets("Coverage Data").Range("A2:AD2")

            Set C = .Rows(1).Find(R.Value, , , xlWhole, , 0)
            If Not C Is Nothing Then
                .Columns(C.Column).Copy R
            Else
                Msg = vllf & R.Value
            End If
        Next

        Application.CutCopyMode = False     
    End With

    If Len(Msg) Then MsgBox "Done" & Msg
End Sub

单击以下代码时运行。什么都没发生。请帮忙有什么不对?没有错误

1 个答案:

答案 0 :(得分:0)

右键单击按钮,然后单击“指定宏”。单击按钮时,选择要触发的宏。然后点击确定。就是这样。