[英]excel that automatically convert cell range to picture on another sheet and automatically update
I want to creat an excel workbook that can convert cell rang on a sheet to picture on another sheet and is capable of authomatically updating the picture should there be any modification on the source sheet. 我想创建一个Excel工作簿,该工作簿可以将工作表上的单元格范围转换为另一工作表上的图片,并且能够对源工作表上的任何内容进行自动更新。 I have no macros background. 我没有宏背景。
Here is an example that you can adapt. 这是您可以适应的示例。 We want to capture changes to range C3:F10 我们想要捕获范围C3:F10的更改
These are input changes rather than the result of calculation. 这些是输入更改,而不是计算结果。
If the cells in this block are changed, the block is copied as Picture and the Picture pasted in Sheet3 near cell C5 如果更改了该块中的单元格,则将该块复制为“图片”,并将“图片”粘贴到Sheet3中靠近单元格C5的位置
Insert the following Event macro in the worksheet code area: 在工作表代码区域中插入以下事件宏:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r1 As Range, r2 As Range, sv As Range
Dim sh As Worksheet
Set r1 = Range("C3:F10")
Set r2 = Sheets("Sheet3").Range("C5")
If Intersect(Target, r1) Is Nothing Then Exit Sub
Set sv = Selection
Set sh = ActiveSheet
Application.EnableEvents = False
r1.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Sheets("Sheet3").Select
On Error Resume Next
ActiveSheet.Shapes("Latest Snap").Delete
On Error GoTo 0
r2.Select
ActiveSheet.Paste
Selection.Name = "Latest Snap"
sh.Select
sv.Select
Application.EnableEvents = True
End Sub
Because it is worksheet code, it is very easy to install and automatic to use: 因为它是工作表代码,所以非常易于安装和自动使用:
If you have any concerns, first try it on a trial worksheet. 如果您有任何疑问,请先在试用版工作表上尝试一下。
If you save the workbook, the macro will be saved with it. 如果您保存工作簿,则宏将随其一起保存。 If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx 如果您在2003年以后使用Excel版本,则必须将文件另存为.xlsm而不是.xlsx
To remove the macro: 删除宏:
To learn more about macros in general, see: 要总体上了解有关宏的更多信息,请参见:
http://www.mvps.org/dmcritchie/excel/getstarted.htm http://www.mvps.org/dmcritchie/excel/getstarted.htm
and 和
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see: 要了解有关事件宏(工作表代码)的更多信息,请参见:
http://www.mvps.org/dmcritchie/excel/event.htm http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work! 必须启用宏才能使其正常工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.