Are you ready for Spreadsheet Day on October 17th? Maybe you can add a Spreadsheet Day message to all your workbooks, using the technique described in this blog post, so a macro runs when worksheet changed. I'm sure your co-workers would enjoy that!

您准备好在10月17 日的电子表格日吗? 也许您可以使用本博客文章中介绍的技术将Spreadsheet Day消息添加到所有工作簿中,以便在工作表更改时运行宏。 我相信您的同事会喜欢的!

任务:提醒用户填写海关表格 (The Mission: Remind Users to Fill in Customs Form)

In this example, the workbook has an order form, with a data validation drop down list, where you can select a customer name.

在此示例中,工作簿具有一个订单表单,以及一个数据验证下拉列表 ,您可以在其中选择一个客户名称。

There are VLOOKUP formulas that pull the address information for the selected customer, to fill in the top of the Order Form sheet. If the customer is located in Canada, you'd like to remind the user to fill in a customs form.

有VLOOKUP公式可为选定客户提取地址信息,以填写“订单表”的顶部。 如果客户位于加拿大,则需要提醒用户填写海关表格。

创建一个工作表更改宏 (Create a Worksheet Change Macro)

By using Event code in Excel VBA, you can make a macro run automatically if something happens on the worksheet. In this example, you want the macro to run if there is a change on the worksheet.

通过在Excel VBA中使用事件代码,如果工作表上发生任何事情,您可以使宏自动运行。 在本示例中,如果工作表上有更改,您希望宏运行。

The following code will make a message appear when the selected customer is in Canada (cell E7).

当选定的客户在加拿大(单元格E7)时,以下代码将显示一条消息。

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("E7").Value = "Canada" Then
MsgBox "Please fill in customs form"
End If
End Sub

仅在特定单元格更改时显示消息 (Show Message Only When Specific Cell is Changed)

On a worksheet where there are multiple cells that can be changed, you might want the message to appear only when a specific cell is changed. In the order form, the message should appear after the customer name is selected, but not every time a product or quantity is entered.

在可以更改多个单元格的工作表上,您可能希望仅在更改特定单元格时显示消息。 在订单中,该消息应在选择客户名称之后出现,但并非每次输入产品或数量时都出现。

You can add a couple of lines of code, so it only runs when cell B5 is changed (the customer name).

您可以添加几行代码,因此它仅在更改单元格B5(客户名称)时运行。

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$5" Then
If Range("E7").Value = "Canada" Then
MsgBox "Please fill in customs form"
End If
End If
End Sub

Now the message box will only appear if cell B5 was changed, and the customer is located in Canada.

现在,仅在更改单元格B5并且客户位于加拿大的情况下,才会显示该消息框。

观看Excel工作表事件宏视频 (Watch the Excel Worksheet Event Macro Video)

To see the steps for creating an Excel Worksheet Change Event macro, watch this short Excel video tutorial.

若要查看创建Excel工作表更改事件宏的步骤,请观看此简短的Excel视频教程。

演示地址

下载样本工作簿 (Download the Sample Workbook)

To see the code, and experiment with the Order Form macro, you can download the Order Form Event Code workbook.

要查看代码并尝试使用Order Form宏,您可以下载Order Form事件代码工作簿 。

The file is in Excel 2007/2010 macro enabled format, and is zipped. After you unzip and open the file, enable the macros, so you can see the message box. ________

该文件为启用Excel 2007/2010宏的格式,并已压缩。 解压缩并打开文件后,启用宏,这样您就可以看到消息框。 ________

翻译自: https://contexturesblog.com/archives/2010/10/13/excel-vba-macro-runs-when-worksheet-changed/


http://www.taodudu.cc/news/show-5813469.html

相关文章:

  • 在Python中运行Excel的VBA宏
  • 网络渗透测试实验——网络扫描与网络侦察
  • 【王道】计算机网络网络层(三)
  • 【已解决】米家摄像头云台版扫不出二维码的问题;
  • 推荐几个出论文的好方向!!!
  • 申请AI方向研究型博士、硕士指南
  • 天使投资人王利杰解读智能硬件创业趋势
  • spleeter消音利器 linux下安装
  • Linux基础知识与命令
  • xml基础知识(一)
  • FFmpeg 基础知识
  • 【Linux】进程基础知识
  • 计算机基础知识的判断题,计算机基础知识判断题(12)
  • 如何使用labview生成二维码
  • 【Microsoft Edge】如何彻底卸载 Edge
  • 叶罗丽颜值测试软件齐娜多少分,叶罗丽仙子:美颜相机测真实年龄,王默出乎意料,齐娜仅5岁?...
  • 用计算机弹出魔法城堡,四川版五年级小学下册信息技术教案.doc
  • Unity_关于我写爆裂魔法那些事(氛围渲染流彩描边星星与其发射系统的实现)
  • CSS魔法(五)项目实战
  • 了解3D世界的黑魔法 - 纯Java构造一个简单的3D渲染引擎
  • ZED2代相机+nvidia jetson AGX xavier踩坑记录
  • 使用Python+Flask+OpenCV构建一个相机应用程序
  • 渲染中的光和材质的数学魔法
  • 小白相机的视频生成方案
  • 相机照片过曝怎么修复?这些方法值得收藏
  • 程序员们,快把这款AI“魔法”做到手机相机里,求求了
  • URP Panini Projection 魔法
  • iOS自定义相机Demo
  • 短视频Demo模块:魔法相机、拍摄、导入裁剪、导入编辑的差异
  • Unity3d六 unity3d资源解析(意义、来源、编辑和查看工具)

Excel VBA –更改工作表后运行宏相关推荐

  1. Excel vba引用工作表的三种写法

    文章介绍vba引用工作表名称的三种不同写法. vba引用工作表是我们在学习VBA过程中很常用. 本文提供三种vba引用工作表的代码,通过这三种方式都可以实现vba引用工作表名. 方法一:Sheets( ...

  2. Excel VBA之工作表

    Sheets/Worksheets 方法:Select Add Delete Copy 属性:Name Count Sub 宏1()'选择工作表 'Sheet1.Select 'Sheets(&quo ...

  3. 如何在Excel中更改工作表选项卡的颜色

    By default, inactive worksheet tabs in Excel are gray, and active or selected worksheet tabs are whi ...

  4. 在excel UiPath中重命名或更改工作表名称

    在excel UiPath中重命名或更改工作表名称 很多时候我们使用excel来自动化业务流程. 我们通过 excel 获取自动化的输入数据,或者我们需要将 excel 作为输出发送给业务用户. 假设 ...

  5. VBA禁止更改工作表名称

    'VBA禁止更改工作表名称 Private Sub workbook_sheetselectionchange(ByVal sh As Object, ByVal target As Range)If ...

  6. excel链接隐藏工作表_自动隐藏Excel工作表

    excel链接隐藏工作表 When you build a workbook for other people to use, there might be worksheets that can s ...

  7. 如何在Excel中对工作表进行分组

    If you're editing multiple worksheets in Microsoft Excel, it might be helpful to group them together ...

  8. 2019秋季计算机应用基础,2019年秋季考试《计算机应用基础》在线考核试题 在Excel 2010的工作表中...

    2019年秋季考试<计算机应用基础>在线考核试题 在Excel 2010的工作表中 (12页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 14 ...

  9. Microsoft Excel 教程「3」:如何在 Excel 中打印工作表?

    欢迎观看 Microsoft Excel 教程,小编带大家学习 Microsoft Excel 的使用技巧,了解如何在 Excel 中打印工作表. 可打印全部或部分工作表,可一次打印一个,也可一次打印 ...

最新文章

  1. 物联网安全只有最薄弱的环节才有保障
  2. 基于cookie的SSO单点登录系统
  3. 软件测试中的α测试、β测试和λ测试
  4. 实用计算机技术选修,实用计算机组装与维护选修课学习心得
  5. php引入类的位置,php如何在一个类中引入另外一个类
  6. lucene 第一天
  7. tooltip.css-2.0文档
  8. phpcmsV9留言板 - 提交后提示页UI自定义效果
  9. bz2解压命令_Java压缩技术 - tar.bz2解压缩
  10. Java-ArrayList.Itr类(Iterator的实现)
  11. 《第一行代码》学习笔记12-UI(1)
  12. html 字体最小多少,浏览器最小显示12px字体的解决方法
  13. javassist修炼笔记
  14. 前端网络基础-GET和POST的区别
  15. 2019年计算机类毕业设计论文题目推荐
  16. Discarding record on action DISCARD on error 0
  17. 全局壁纸美化v3.0安卓版
  18. threading.Thread.setDaemon()方法
  19. MSRA显著性检测数据集
  20. 一款在线视频 App,基于 Material Design + MVP + RxJava + Retrofit + Realm + Glide

热门文章

  1. 《汇编语言》- 读书笔记 - 第1章-基础知识
  2. 派对语音游戏互动平台
  3. Oracle数据库中的多表关联查询
  4. vmware如果在安装苹果系统提示“安装 macOS xxx“应用程序副本已损坏,不能用来安装macOS
  5. 第一讲如何培养孩子养成良好的学习习惯
  6. utd2102cex_ml utd 9机器学习数据的最新生命
  7. [时态]二十、现在完成时态 2
  8. php中的数据结构详解
  9. python字符串操作函数总结
  10. 【基础算法 】文本相似度计算