显示“活动” Excel Userform中的图表数据 [英] Displaying "live" chart data in Excel Userform

查看:648
本文介绍了显示“活动” Excel Userform中的图表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我一直在研究在用户窗体中显示图表的模式。一般的共识似乎是,你必须将图表保存为.GIF文件,然后将其在用户窗体中作为图像上传,但是,这将意味着任何使用userform的人必须将文件保存为图像为了查看信息(我不相信任何我的同事会花时间学习如何做到这一点,他们只是想快速图表视图)。

So, I have been researching the modes of displaying charts in a userform. The general consensus seems to be that you have to save the chart as a .GIF file and then upload this within the userform as an image, however, this would then mean that anyone using the userform would have to have the file saved as an image in order to view the information (and I do not believe that any of my associates will take the time to learn how to do this, they just want a quick chart-view).

有没有解决方法来显示用户表单内的图表(不断更新的数据)?我尝试了多种途径,没有找到任何东西...此外,我的Excel 2013似乎没有在工具箱中的Microsoft Office图表选项,这是已经改变了吗?

Is there a workaround to display the chart (which is constantly being updated by data that comes in) within a userform? I have tried multiple avenues and am not finding anything... Also, my Excel 2013 does not appear to have the Microsoft Office Charts option within the Toolbox, is this something that has been changed?

谢谢!

推荐答案

案例1:如果图表在工作表上,

Case 1: If the chart is on the worksheet, it will be easier as below:

Private Sub UserForm_Initialize()
    Dim Fname As String

    Call SaveChart
    Fname = ThisWorkbook.Path & "\temp1.gif"
    Me.Image1.Picture = LoadPicture(Fname)
End Sub

Private Sub SaveChart()
    Dim MyChart As Chart
    Dim Fname As String

    Set MyChart = Sheets("Data").ChartObjects(1).Chart
    Fname = ThisWorkbook.Path & "\temp1.gif"
    MyChart.Export Filename:=Fname, FilterName:="GIF"
End Sub

$情况2:如果图表不在工作表上,您可能需要创建一个临时图表,将其保存为GIF,将其删除,最后加载图片{

Case 2: If chart is not on the worksheet, you may need to create a temporary chart, save it as GIF, delete it, and finally load the picture {

Me.Image1.Picture = LoadPicture(Fname)

}当用户初始化时。

案例1更容易编码。上面的代码仍然工作,即使我剪切和粘贴图表在以后隐藏的工作表。

Case 1 is easier to code. The above code still works even I cut and paste the chart in a later-hidden worksheet.

这篇关于显示“活动” Excel Userform中的图表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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