通过双击启动宏 [英] Start macro by double click

查看:32
本文介绍了通过双击启动宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过双击单元格来启动宏.

I'm trying to start a macro through double clicking a cell.

我直接从互联网上复制了此代码,但是当我双击单元格C40时它不起作用.

I copied this code directly from the internet, but it is not working when I double click the cell C40.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Application.Intersect(Target, Range("C40")) Is Nothing Then
        Cancel = True
        SelectPayFreq.Show
    End If
End Sub

推荐答案

工作表事件的代码必须放置在模块中,而不是常规模块中的正确工作表.

The code for worksheet events must be placed in the module for a proper worksheet not in a regular module.

这篇关于通过双击启动宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆