为图表

时间:2018-06-14 16:14:54

标签: excel vba excel-vba

我有两组过时的数据: | 9/15/2015 | 1400 | a | | | | 9/15/2015 | 1400 | a | | 9/15/2015 | 1401 | b | | | | 9/15/2015 | 1398 | c | | 9/15/2015 | 1398 | c | | | | 9/16/2015 | 1401 | c | | 9/15/2015 | 1397 | d | | | | 9/17/2015 | 1402 | a | | 9/16/2015 | 1398 | a | | | | 9/17/2015 | 1403 | b | | 9/20/2015 | 1399 | d | | | | 9/20/2015 | 1404 | b | | 9/21/2015 | 1401 | b | | | | 9/20/2015 | 1406 | c | | | | | | | | 9/20/2015 | 1407 | d | | | | | | | | 9/20/2015 | 1408 | b |

绘制图形时,我没有显示所有日期和项目。如果日期在同一行上不同,那么它会在最短的表格中切断并且点不会对齐。Initial graph with this table 为了纠正这个问题,我需要将数据移位以匹配 所以显示r3c7 9/16/2015。我需要在该表中添加两行,并使用与第1行第3行和第4行匹配的日期填充它们,并匹配第8列(1398)中的值,以便使数据在图表中正确排列。

如何通过VBA实现这一点,因为表中的差异可能非常显着。 要么 有没有更好的方法来格式化图表以自动排列所有数据?

我正在使用代码自动生成图表。我发布了另一个关于Chart not Sizing to larger range的问题 我在这里问的问题是试图解决这个问题。   所以这就是所需的输出应该是使图形排列并使用两个表的全部范围: | 9/15/2015 | 1400 | a | | | | 9/15/2015 | 1400 | a | |-----------|------|---|---|---|---|-----------|------|---| | 9/15/2015 | 1401 | b | | | | 9/15/2015 | 1400 | | | 9/15/2015 | 1401 | | | | | 9/15/2015 | 1398 | c | | 9/15/2015 | 1398 | c | | | | 9/15/2015 | 1398 | | | 9/15/2015 | 1397 | d | | | | 9/15/2015 | 1398 | | | 9/16/2015 | 1398 | a | | | | 9/16/2015 | 1398 | | | 9/16/2015 | 1398 | | | | | 9/16/2015 | 1401 | c | | 9/16/2015 | 1399 | d | | | | 9/16/2015 | 1401 | | | 9/17/2015 | 1399 | | | | | 9/17/2015 | 1402 | a | | 9/17/2015 | 1399 | | | | | 9/17/2015 | 1403 | b | | 9/20/2015 | 1401 | b | | | | 9/20/2015 | 1404 | b | | 9/20/2015 | 1401 | | | | | 9/20/2015 | 1406 | c | | 9/20/2015 | 1401 | | | | | 9/20/2015 | 1407 | d | | 9/20/2015 | 1401 | | | | | 9/20/2015 | 1408 | b | | | | | | | | | | | 请注意,日期从1个表复制到另一个表,数值向下复制。Graph that depicts the values relative to the time period of either table

1 个答案:

答案 0 :(得分:0)

我发现了一个简单而优雅的解决方案应该可以很好地工作。 我在这里找到了答案:https://peltiertech.com/plot-two-time-series-with-different-dates/

只需将所有日期值放入一列即可! | 9/15/2015 | 1400 | a | | | | | | | | 9/15/2015 | 1401 | b | | | | | | | | 9/15/2015 | 1398 | c | | | | | | | | 9/15/2015 | 1397 | d | | | | | | | | 9/16/2015 | 1398 | a | | | | | | | | 9/16/2015 | 1399 | d | | | | | | | | 9/20/2015 | 1401 | b | | | | | | | | 9/15/2015 | | | 1400 | a | | | | | | 9/15/2015 | | | 1398 | c | | | | | | 9/16/2015 | | | 1401 | c | | | | | | 9/20/2015 | | | 1401 | a | | | | | | 9/20/2015 | | | 1401 | b | | | | | | 9/20/2015 | | | 1404 | b | | | | | | 9/20/2015 | | | 1406 | c | | | | | | 9/20/2015 | | | 1407 | d | | | | | | 9/20/2015 | | | 1408 | b | | | | |