- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
首先,我想说这个网站是天赐之物!
我每个月都有一系列数据 B2:AS40。月份在 A2:AS2 中,A2:A40 中是一个名称列表,所有这些都在“Sheet1”中
经过之前的一些搜索,我得出了以下结果,该脚本为每一行创建一个新图表,创建一个标题并以第 6 个月的间隔放入 MajorGridlines,但不绘制数据。我一生都无法弄清楚为什么!!
请帮忙
Sub test()
Dim Row As Integer
Dim ws As Worksheet
Dim rng As Range
Set ws = Sheets("Sheet1") 'Change this to: Set ws = Sheets("Master Sheet")
For Row = 3 To 5
Set rng = ws.Range("B3:AS3").Offset(Row, 0) 'Change to (I'm guessing here): ws.Range("$J$7:$Y$7").Offset(Row, 0)
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range(ws.Name & "!" & rng.Address)
ActiveChart.ChartType = xlLineMarkers
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).XValues = "='Sheet1'!$B$1:$AS$1" 'Change to "='Master Sheet'!$J$2:$Y$2"
ActiveChart.SeriesCollection(1).Name = ws.Range("A1").Offset(Row, 0).Value 'Change this to whatever you want to name the graphs. This is currently set to dynamicly name each graph by the series name set in Column A.
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:=ws.Range("A1").Offset(Row, 0).Value 'uncomment this line to put on new sheet
With ActiveChart
.HasLegend = False
.SeriesCollection(1).Trendlines.Add(Type:=xlMovingAvg, Period:=12).Select
'.Axes(xlCategory).TickMarkSpacing = 6
.Axes(xlCategory).HasMajorGridlines = True
End With
With ActiveChart.SeriesCollection(1).Trendlines(1)
.Border.ColorIndex = 33
.Border.Weight = xlMedium
.Border.LineStyle = xlDashDotDot
End With
ws.Select 'Need to go back to worksheet
Next Row
Set ws = Nothing
Set rng = Nothing
End Sub
示例数据:
Apr-10 May-10 Jun-10 Jul-10 Aug-10 Sep-10 Oct-10 Nov-10 Dec-10 Jan-11 Feb-11 Mar-11 Apr-11 May-11 Jun-11 Jul-11 Aug-11 Sep-11 Oct-11 Nov-11 Dec-11 Jan-12 Feb-12 Mar-12 Apr-12 May-12 Jun-12 Jul-12 Aug-12 Sep-12 Oct-12 Nov-12 Dec-12 Jan-13 Feb-13 Mar-13 Apr-13 May-13 Jun-13 Jul-13 Aug-13 Sep-13 Oct-13 Nov-13
Company 1 14666 12795 10874 12560 13098 12660 14618 14031 14654 13016 11012 13912 14038 12262 12997 11295 12899 12878 14922 10493 13714 11513 12385 10528 13025 11637 11856 14794 10874 13286 12393 10164 11660 14948 13325 12689 14623 10368 10476 10386 11751 13766 11134 10497
Company 2 11769 10449 10835 12071 14354 12432 13698 14426 11763 11685 14876 12118 10110 12837 10144 10169 12664 11393 12613 13239 13681 14312 10848 14293 11270 14623 13738 12481 12226 11837 13960 12567 11668 12646 10829 11439 13698 10678 11409 13652 11056 13503 13182 14675
Company 3 13181 11246 11815 14960 11481 10863 10259 12287 13468 10454 12553 14751 10559 13592 14844 10799 11323 13218 13711 12547 14410 14205 10713 13059 12439 14185 11543 11537 11848 11150 12130 14641 13330 12934 12037 14982 11709 10971 13810 10729 13842 14457 14361 13281
Company 4 12223 13097 12032 10047 13361 12067 14420 11880 12270 10718 12367 12327 12542 13593 14858 14567 10096 10166 10580 13860 14581 12268 11613 11423 10472 13811 10801 13333 10324 12594 12745 12127 10944 10979 14404 14943 11067 12009 14457 10598 13409 13781 11553 13000
Company 5 13680 14319 13858 14356 13666 11855 11495 11406 14980 11369 10108 13726 11543 11311 12884 14486 10538 11346 14347 13568 14763 10218 14278 13355 13286 11899 13436 13980 14459 13648 14930 14999 12706 14181 11793 12777 14802 11914 10000 11245 13331 10915 11646 10435
Company 6 10083 10355 12951 13342 11059 13582 11118 14696 10608 11010 13741 13970 11800 13850 12179 13557 14757 13859 13297 14772 13896 11726 13055 13703 10883 11561 12175 13169 12040 10099 11165 12276 11627 12743 12092 12465 10375 10382 11125 14841 13409 12030 13165 12947
Company 7 12146 13011 14596 13182 13859 14605 13945 13826 14808 10528 12939 12123 12995 10259 12733 12132 13464 10246 11535 10440 14336 10856 10514 14316 13434 10513 10310 13833 13510 13442 11008 14883 12794 14255 13858 14184 10891 10429 14478 14679 13519 10498 10731 12438
Company 8 14815 13134 11152 13517 14849 12229 12884 10379 11917 11030 14059 10568 10975 14141 12078 12463 10602 12129 13460 10327 12262 11740 11278 13873 12184 13846 13275 10480 13078 13244 12005 12734 11160 14214 14511 14042 12153 12066 14280 11756 10621 13704 14137 13754
Company 9 14484 10161 14949 11218 14022 13369 11816 14573 14007 14962 13764 10730 14864 13414 11457 13405 10155 13868 13413 11129 12582 11212 13365 11107 13251 13103 12726 12545 14518 12512 12531 10677 12821 10819 10632 11638 12649 11437 10981 12661 11761 13174 13753 12176
Company 10 12523 14590 12610 10071 10965 14594 11908 14258 13927 10058 10496 11185 14372 12343 14455 11573 10534 10864 10814 12513 14356 10763 11413 10717 12409 14452 12473 11120 14296 12602 12950 12613 13964 14978 10129 13718 14289 13837 14312 12038 10796 10430 12051 11567
将脚本更改为:
脚本每次运行时都不会换行,并且它在新页面上生成的第二个图表只是将其余图表堆积在它们之上!
我开始失去理智了! :(
Sub test()
Dim Row As Long
Dim ws As Worksheet
Dim rng As Range
Set ws = Sheets("Sheet1")
For Row = 3 To 4
Set rng = ws.Range("B3:AS3")
ActiveSheet.Shapes.AddChart.Select
With ActiveChart
.SetSourceData Source:=Range(ws.Name & "!" & rng.Address)
.ChartType = xlLineMarkers
.PlotArea.Select
.SeriesCollection(1).XValues = "='Sheet1'!$A2:$AS2"
.SeriesCollection(1).Name = ws.Range("A1")
.HasLegend = False
.SeriesCollection(1).Trendlines.Add(Type:=xlMovingAvg, Period:=12).Select
.Axes(xlCategory).HasMajorGridlines = True
With .SeriesCollection(1).Trendlines(1)
.Border.ColorIndex = 33
.Border.Weight = xlMedium
.Border.LineStyle = xlDashDotDot
End With
End With
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:=ws.Range("A1").Offset(Row, 0).Value
Next Row
Set rng = Nothing
Set ws = Nothing
End Sub
最佳答案
这是我想要的版本:
使用您的工作簿进行尝试和测试
Option Explicit
Sub test()
Dim ws As Worksheet
Dim ch As Chart
Dim trend As Trendline
Dim rng As Range
Dim i As Long
Set ws = ThisWorkbook.Sheets("Sheet1")
Set rng = ws.Range("$A$3:$AS$3")
For i = 0 To 39
With ws
Set ch = .Shapes.AddChart.Chart.Location(xlLocationAsNewSheet, .Range("A3").Offset(i, 0))
ch.ChartType = xlLineMarkers
ch.SetSourceData Source:=Range(.Name & "!" & rng.Offset(i, 0).Address)
ch.SeriesCollection(1).XValues = "=Sheet1!$B$2:$AS$2"
Set trend = ch.SeriesCollection(1).Trendlines.Add(xlMovingAvg, 12)
With trend.Border
.ColorIndex = 33
.Weight = xlMedium
.LineStyle = xlDashDotDot
End With
Set ch = Nothing
Set trend = Nothing
End With
Next
Set rng = Nothing
Set ws = Nothing
End Sub
我坚持使用 Offset 并声明了大部分图表对象。
希望这会有所帮助。
使用您最近上传的图表查看示例图表的屏幕截图。
Company1,这是示例数据中的第一组数据:
Company3 前几列为零:
Company40 最后几列为零:
关于vba - 在 Excel 中使用 VBA 宏为每一行创建一个新图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20649289/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!