在公式重新计算中仅特定Excel单元格发生更改时调用函数 [英] Call a function when only a specific Excel cell changes on Formula Recalculation

查看:182
本文介绍了在公式重新计算中仅特定Excel单元格发生更改时调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,当工作表中任何单元格的值在重新计算公式时发生更改时,都会调用Worksheet_Calculate.

As far as i know, Worksheet_Calculate is called when the value of any cell in a worksheet changes on Formula recalculation.

有没有办法让我仅在公式重新计算中特定单元格发生变化时才需要调用函数

Is there a way so that i need a function to be called only when a specific cell changes on Formula Recalculation

推荐答案

让我看看我是否正确解释了您的问题.您想知道是否只有在特定单元格(或一组单元格)发生更改时才可以启动宏.

Let me see if I interpret your question correctly. You want to know if it is possible to only kickoff a macro if a particular cell (or group of cells) is changed.

答案是肯定的.稍微调整一下Ed的代码.

The answer is Yes. To tweak Ed's code a little.

Private Sub Worksheet_Change(byval target as range)

    If Not Intersect(target.address, Range("YourCells")) is Nothing Then 
       MyMacro()
    End If

End Sub

我认为您对功能"的使用将人们甩了出去.这就是埃德的答案如此详尽的原因.

I think your use of "function" is throwing people off. That's why Ed's answer is so elaborate.

好的.您可能正确地陈述了您的问题,而您只是想提高效率.在这种情况下,埃德(Ed)的答案可以解决您的直接问题,但是当您更改其他单元格时,电子表格将不会自动计算.

Ok. It is possible that you stated your question correctly and you just want to gain efficiency. In that case, Ed's answer solves your immediate problem, but will cause the spreadsheet NOT to calculate automatically when you change other cells.

这篇关于在公式重新计算中仅特定Excel单元格发生更改时调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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