更改单元格颜色,其中vba已更改值VBA

时间:2018-05-07 16:53:48

标签: excel vba target byval

我是VBA的新手,所以如果我听起来很蠢,请耐心等待。

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

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

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

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

请注意,VBA未写入目标文件中。由于客户端请求,该文件不能是xlsm格式。

提前致谢!!

1 个答案:

答案 0 :(得分:0)

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

  

您可以使用.bat文件将其复制到其addins文件夹中。

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