更改 vba 已更改值 VBA 的单元格颜色

Change cell colour where vba has changed the value VBA

我是 VBA 的新手所以如果我听起来很愚蠢请多多包涵-

背景资料: 我正在尝试自动化我们每季度更新的工作簿 - 我想通过更改这些单元格的背景颜色来显示我的 VBA 脚本更改了哪些单元格,以便我可以在开发脚本时跟踪它们。也适用于 VBA 零知识的同事,他将查看数据并继续手动更新文件。

现在我注意到有一个我可以使用的事件过程:

Private Sub Worksheet_Change(ByVal Target As Range)
  Target.Interior.Color = RGB(255, 253, 130)
End Sub

据我了解,即使更改由 VBA 完成,它也可以标记单元格,但我不知道如何使用我的 VBA 脚本实现它。我是以某种方式将其插入到我的一般程序中,还是必须将其嵌入到更新的目标文件中?

请注意,VBA 没有写在目标文件中。因客户要求,文件不能为xlsm格式。

提前致谢!!

我会为此创建一个 Excel 加载项并将其安装到您同事的机器上。然后根据您的要求将代码与客户端文件分开。

You can use a .bat file to copy it out to their addins folder.

REM
REM     /E   = Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T. 
REM     /D:m-d-y = Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time. 
REM     /K   = Copies attributes. Normal Xcopy will reset read-only attributes. 
REM     /Q   = Does not display file names while copying. 
REM     /R   = Overwrites read-only files. 
REM     /Y   = Suppresses prompting to confirm you want to overwrite an existing destination file. 
REM

XCOPY ".\YourAddin.xlam" "%AppData%\Microsoft\AddIns\YourAddin.xlam" /E /K /Q /R /Y /D