VBA批量绘制动态化数据图表

news2025/1/13 7:48:06

对于大多数使用的VBA的人来说,处理excel工作簿中批量数据是日常工作中常见的情形,但与此同时,VBA在批量绘图方面同样有简洁快速的特点。

说起Excel画图表,考虑一个问题,excel图表的本质是什么?很多人会不假思索地回答,数据图形化的一种表达形式。是的,excel图表是图表框架加入原始数据形成的,这很容易理解,因为可以在excel不用任何数据就可以绘制excel图表,这表明图表中的框架不依附于数据可以独立存在。

有人可能会好奇,excel绘制图表就直接原始数据插入图表就可以了,为什么要讨论excel图表和数据的关系呢?因为在实际应用中,当已知excel图表形式,即知道要画什么图表,但是不知道原始数据,可以先画出框架,再填入数据源,有固定图表框架这种情况下,有一组新数据就会有一个新图表。

有了以上基础,可以参考以下实战案例:有8个工作簿,每一个工作簿都有若干行和列的数据,行坐标是日期,列坐标是数据项目名称,工作簿中包含有Avg. Best FFL, Avg. Defocus, Avg. DOF, Monitor MT,这四项的列坐标在不同工作簿的位置不一样,现需要在一张工作簿显示这四项最近一个月的数据。

分析以上需求可知,在一页显示8张工作簿的4项需要32张图表才能满足需求,若同时批量画出来必然不美观,此时可考虑动态图表,即点击某张工作簿标题就显示这张工作簿包含的四项内容;又因为需要显示最近一个月的数据,因此数据源需要及时更新,而四张图表则可以通过VBA代码批量搭框架加入数据源画出来。

Step 1: 将原始数据导入到多个空白工作簿作为数据源;

导入
数据源
空工作簿
多个数据源工作簿

Step 2: 建立空白图表框架,将工作簿的某列数据导入框架得到图表,重复4次即可得到一页4张;

数据
批量
图表框架
单个数据图表
多个数据图表

Step 3: 利用列表框动态触发事件,更新数据源可得到新的图表;

具体实现方法如下:


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
'代码块1:这部分代码是利用子模块将多个工作簿数据集中在一张工作簿多个工作表。
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 

Sub Daily_Monitor()
Application.DisplayAlerts = False
Dim wks As Worksheet, wks1 As Worksheet
For Each wks In ThisWorkbook.Sheets
    If wks.Name <> "IMPRO Monitor Summary" And wks.Name <> "Dynamic Summary" Then
    wks.Delete
    End If
Next
Call Iolite_Post
Call Iolite_Pre
Call Quartz_Monitor
Call RADAR2_Monitor
Call Ammolite_Monitor
Call OVM7690_Monitor
Call Garnet_Monitor
Call Spinel_Monitor
For Each wks1 In ThisWorkbook.Sheets
    If wks1.Name <> "IMPRO Monitor Summary" And wks1.Name <> "Ammolite_Pre_04" Then
    wks1.Columns.Hidden = False
    End If
Next
Application.DisplayAlerts = True
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
'子代码模块:这部分代码是将每一张工作簿的原始数据复制到每一张命名相同的工作表。
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
Sub Iolite_Post()
Dim ws As Worksheet
ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\Iolite\DAILY MONITOR\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\Iolite\DAILY MONITOR\"
Workbooks.Open (pth & "Iolite Record.xlsx")
For Each ws In ActiveWorkbook.Sheets
    If ws.Name = "CIP4T11-POST-850nm" Then
        ws.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "Iolite_Post_11"
'    ElseIf ws.Name = "CIP4T02" Then
'        ws.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
'        ThisWorkbook.ActiveSheet.Name = "Iolite_Post_02"
    End If
Next ws
Workbooks("Iolite Record.xlsx").Close 0
End Sub

Sub Iolite_Pre()
Dim ws1 As Worksheet
ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\Iolite\DAILY MONITOR\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\Iolite\DAILY MONITOR\"
Workbooks.Open (pth & "Iolite IR850 Record.xlsx")
For Each ws1 In ActiveWorkbook.Sheets
'    If ws1.Name = "CIP4T03" Then
'        ws1.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
'        ThisWorkbook.ActiveSheet.Name = "Iolite_Pre_03"
    If ws1.Name = "CIP4T05-PRE" Then
        ws1.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "Iolite_Pre_05"
    ElseIf ws1.Name = "CIP4T08" Then
        ws1.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "Iolite_Pre_08"
    End If
Next ws1
Workbooks("Iolite IR850 Record.xlsx").Close 0
End Sub

Sub Quartz_Monitor()
Dim ws2 As Worksheet
ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\Quartz\ENG\Daily Monitor\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\Quartz\ENG\Daily Monitor\"
Workbooks.Open (pth & "Quartz Daily Monitor Record-v1.0(CIP4T03).xlsm")
For Each ws2 In ActiveWorkbook.Sheets
    If ws2.Name = "Record" Then
        ws2.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "Quartz_Pre_03"
    End If
Next ws2
Workbooks("Quartz Daily Monitor Record-v1.0(CIP4T03).xlsm").Close 0
End Sub

Sub RADAR2_Monitor()
On Error Resume Next
Dim ws3 As Worksheet, ws4 As Worksheet
ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\OVM6211-RADA-R2\DAILY MONITOR\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\OVM6211-RADA-R2\DAILY MONITOR\"

Workbooks.Open (pth & "RADA R2 Pre Record.xlsx")
For Each ws3 In ActiveWorkbook.Sheets
    If ws3.Name = "CIP4T10" Then
        ws3.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "RADA-R2_Pre_10"
    End If
Next ws3
Workbooks("RADA R2 Pre Record.xlsx").Close 0

ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\OVM6211-RADA-R2\DAILY MONITOR\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\OVM6211-RADA-R2\DAILY MONITOR\"
Workbooks.Open (pth & "RADA R2 Post Record.xlsx")

For Each ws4 In ActiveWorkbook.Sheets
    If ws4.Name = "CIP4T02" Then
        ws4.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "RADA-R2_Post_02"
    End If
Next ws4
Workbooks("RADA R2 Post Record.xlsx").Close 0
End Sub


Sub Ammolite_Monitor()
On Error Resume Next
Dim ws5 As Worksheet
ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\Ammolite\ENG\Daily Monitor\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\Ammolite\ENG\Daily Monitor\"
Workbooks.Open (pth & "Ammolite Daily Monitor Record-v3.1.xlsm")

For Each ws5 In ActiveWorkbook.Sheets
    If ws5.Name = "Record" Then
        ws5.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "Ammolite_Pre_04"
    End If
Next ws5
Workbooks("Ammolite Daily Monitor Record-v3.1.xlsm").Close 0
End Sub


Sub OVM7690_Monitor()
Dim ws6 As Worksheet
ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\VMA001\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\VMA001\"
Workbooks.Open (pth & "OVM7690 Correlation Result.xlsx")
For Each ws6 In ActiveWorkbook.Sheets
    If ws6.Name = "Monitor Record" Then
        ws6.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "7690_01"
    End If
Next ws6
Workbooks("OVM7690 Correlation Result.xlsx").Close 0
End Sub


Sub Garnet_Monitor()
On Error Resume Next
Dim ws7 As Worksheet, ws9 As Worksheet
ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\Garnet\ENG\Daily Monitor\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\Garnet\ENG\Daily Monitor\"
Workbooks.Open (pth & "Garnet Daily Monitor Record-CIP4T15 &CIP4T12.xlsm")
For Each ws7 In ActiveWorkbook.Sheets
    If ws7.Name = "Record" Then
        ws7.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "Garnet_Pre_12"
    End If
Next ws7
Workbooks("Garnet Daily Monitor Record-CIP4T15 &CIP4T12.xlsm").Close 0
Workbooks.Open (pth & "Garnet Daily Monitor Record-CIP4T13.xlsm")
For Each ws9 In ActiveWorkbook.Sheets
    If ws9.Name = "Record" Then
        ws9.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "Garnet_Pre_13"
    End If
Next ws9
Workbooks("Garnet Daily Monitor Record-CIP4T13.xlsm").Close 0
End Sub


Sub Spinel_Monitor()
Dim ws8 As Worksheet
ChDrive Z
ChDir "Z:\Fab-Transfer\Impro4 Raw-Data\Spinel\Macro\"
pth = "Z:\Fab-Transfer\Impro4 Raw-Data\Spinel\Macro\"
Workbooks.Open (pth & "Spinel Daily Monitor Record-V2.xlsm")
For Each ws8 In ActiveWorkbook.Sheets
    If ws8.Name = "Record" Then
        ws8.Copy after:=Workbooks("IMPRO Monitor Summary.xlsm").Sheets("IMPRO Monitor Summary")
        ThisWorkbook.ActiveSheet.Name = "Spinel_Pre_14"
    End If
Next ws8
Workbooks("Spinel Daily Monitor Record-V2.xlsm").Close 0
End Sub


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
'代码块2:这部分代码是创建图表框架,然后定义工作簿的数据源,利用ListBox clik事件绘制图表
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
Private Sub ListBox1_Click()
Application.DisplayAlerts = False
Sheets("IMPRO Monitor Summary").ChartObjects.Delete
Dim shp1 As Shape, shp2 As Shape, shp3 As Shape, shp4 As Shape
Dim arr1, arr2, arr3, arr4, arr5, arr6, arr7, arr8
Dim k As Integer, i As Integer
Dim ser As Series, pt As Point
Dim ws As Worksheet
With Sheets("IMPRO Monitor Summary").Shapes
    Set shp1 = .AddChart(xlLineMarkers, 5, 0, 320, 220)
    Set shp2 = .AddChart(xlLineMarkers, 325, 0, 320, 220)
    Set shp3 = .AddChart(xlLineMarkers, 5, 220, 320, 220)
    Set shp4 = .AddChart(xlLineMarkers, 325, 220, 320, 220)
End With

'    Iolite_x = Array("Iolite_Pre_03" Or "Iolite_Pre_05" Or "Iolite_Pre_08")
'    For x = 1 To 3
'    Next
    Select Case ListBox1.Value

    Case "Quartz_Pre_03"
        With shp1.Chart
            .SetSourceData Union(Sheets("Quartz_Pre_03").Range("I1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Quartz_Pre_03").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Quartz_Pre_03").Columns("I:I").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 0.0025 Or ser.Values(k) < -0.0025 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("Quartz_Pre_03").Range("P1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Quartz_Pre_03").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Quartz_Pre_03").Columns("P:P").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("Quartz_Pre_03").Range("Q1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Quartz_Pre_03").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Quartz_Pre_03").Columns("Q:Q").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.01: .Axes(xlValue).MaximumScale = 0.01
        End With
        With shp4.Chart
            .SetSourceData Source:=Sheets("Quartz_Pre_03").Range("S1048576").End(xlUp)(-28, 1).Resize(30, 17)
            .Axes(xlValue).MinimumScale = -3: .Axes(xlValue).MaximumScale = 3
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With
        arr1 = Sheets("Quartz_Pre_03").Range("S2:AI2")
'        arr2 = Sheets("Iolite_Pre_03").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
        i = 1
        For Each ser In shp4.Chart.SeriesCollection
            ser.Name = arr1(1, i)
            i = i + 1
        Next
'        j = 1
'        Dim xcht As ChartObject, xser As Series
'        For Each xcht In Sheets("IMPRO Monitor Summary").ChartObjects
'            For Each xser In xcht.Chart.SeriesCollection
'                xser.XValues = arr2(j, 1)
'                j = j + 1
'            Next
'        Next
'        cht.FullSeriesCollection.XValues = arr1
'''    cht1.Chart.Legend.Position = xlLegendPositionBottom
        
    Case "Iolite_Pre_05"
        With shp1.Chart
            .SetSourceData Union(Sheets("Iolite_Pre_05").Range("L1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Pre_05").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Pre_05").Columns("L:L").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 2.5 Or ser.Values(k) < -2.5 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("Iolite_Pre_05").Range("J1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Pre_05").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Pre_05").Columns("J:J").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = 0: .Axes(xlValue).MaximumScale = 0.01
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("Iolite_Pre_05").Range("K1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Pre_05").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Pre_05").Columns("K:K").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = 34: .Axes(xlValue).MaximumScale = 44
        End With
        With shp4.Chart
            .SetSourceData Sheets("Iolite_Pre_05").Range("P1048576").End(xlUp)(-28, 1).Resize(30, 17)
            .Axes(xlValue).MinimumScale = -3: .Axes(xlValue).MaximumScale = 3
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With
        arr1 = Sheets("Iolite_Pre_05").Range("P2:AF2")
'        arr2 = Sheets("Iolite_Pre_05").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
        i = 1
        For Each ser In shp4.Chart.SeriesCollection
            ser.Name = arr1(1, i)
            i = i + 1
        Next
        
    Case "Iolite_Pre_08"
        With shp1.Chart
            .SetSourceData Union(Sheets("Iolite_Pre_08").Range("L1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Pre_08").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Pre_08").Columns("L:L").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 2.5 Or ser.Values(k) < -2.5 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("Iolite_Pre_08").Range("J1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Pre_08").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Pre_08").Columns("J:J").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = 0: .Axes(xlValue).MaximumScale = 0.01
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("Iolite_Pre_08").Range("K1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Pre_08").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Pre_08").Columns("K:K").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = 34: .Axes(xlValue).MaximumScale = 44
        End With
        With shp4.Chart
            .SetSourceData Sheets("Iolite_Pre_08").Range("P1048576").End(xlUp)(-28, 1).Resize(30, 17)
            .Axes(xlValue).MinimumScale = -3: .Axes(xlValue).MaximumScale = 3
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With
        arr1 = Sheets("Iolite_Pre_08").Range("P2:AF2")
'        arr2 = Sheets("Iolite_Pre_08").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
        i = 1
        For Each ser In shp4.Chart.SeriesCollection
            ser.Name = arr1(1, i)
            i = i + 1
        Next

    Case "RADA-R2_Post_02"
        With shp1.Chart
            .SetSourceData Union(Sheets("RADA-R2_Post_02").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("RADA-R2_Post_02").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("RADA-R2_Post_02").Columns("B:B").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 2 Or ser.Values(k) < -2 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("RADA-R2_Post_02").Range("C1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("RADA-R2_Post_02").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("RADA-R2_Post_02").Columns("C:C").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("RADA-R2_Post_02").Range("D1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("RADA-R2_Post_02").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("RADA-R2_Post_02").Columns("D:D").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
        End With
        k = 1
        For Each ser In shp3.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 5 Or ser.Values(k) < -10 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp4.Chart
            .SetSourceData Union(Sheets("RADA-R2_Post_02").Range("E2:I2"), Sheets("RADA-R2_Post_02").Range("E1048576").End(xlUp)(-28, 1).Resize(30, 5))
            .Axes(xlValue).MinimumScale = 0.26: .Axes(xlValue).MaximumScale = 0.31
            .HasTitle = True
            .ChartTitle.Text = "Post FFL In Different Field"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With

    Case "Iolite_Post_11"
        With shp1.Chart
            .SetSourceData Union(Sheets("Iolite_Post_11").Range("C1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Post_11").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Post_11").Columns("C:C").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 2 Or ser.Values(k) < -2 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("Iolite_Post_11").Range("D1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Post_11").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Post_11").Columns("D:D").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("Iolite_Post_11").Range("E1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Iolite_Post_11").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Iolite_Post_11").Columns("E:E").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -10: .Axes(xlValue).MaximumScale = 0
        End With
        k = 1
        For Each ser In shp3.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 5 Or ser.Values(k) < -10 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp4.Chart
            .SetSourceData Union(Sheets("Iolite_Post_11").Range("F2:J2"), Sheets("Iolite_Post_11").Range("F1048576").End(xlUp)(-28, 1).Resize(30, 5))
            .Axes(xlValue).MinimumScale = 0.22: .Axes(xlValue).MaximumScale = 0.27
            .HasTitle = True
            .ChartTitle.Text = "Post FFL In Different Field"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With
        
'    Case "Ruby2_Post_16"
'        With shp1.Chart
'            .SetSourceData Union(Sheets("Ruby2_Post_16").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("Ruby2_Post_16").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("Ruby2_Post_16").Columns("B:B").Range("a2")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
'        End With
'        k = 1
'        For Each ser In shp1.Chart.FullSeriesCollection
'            For Each pt In ser.Points
'                If ser.Values(k) > 2.5 Or ser.Values(k) < -2.5 Then
'                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
'                End If
'                k = k + 1
'            Next
'        Next
'        With shp2.Chart
'            .SetSourceData Union(Sheets("Ruby2_Post_16").Range("C1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("Ruby2_Post_16").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("Ruby2_Post_16").Columns("C:C").Range("a2")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
'        End With
'        With shp3.Chart
'            .SetSourceData Union(Sheets("Ruby2_Post_16").Range("D1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("Ruby2_Post_16").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("Ruby2_Post_16").Columns("D:D").Range("a2")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = 0: .Axes(xlValue).MaximumScale = 10
'        End With
'        k = 1
'        For Each ser In shp3.Chart.FullSeriesCollection
'            For Each pt In ser.Points
'                If ser.Values(k) > 5 Then
'                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
'                End If
'                k = k + 1
'            Next
'        Next
'        With shp4.Chart
'            .SetSourceData Union(Sheets("Ruby2_Post_16").Range("E2:I2"), Sheets("Ruby2_Post_16").Range("E1048576").End(xlUp)(-28, 1).Resize(30, 5))
'            .Axes(xlValue).MinimumScale = 0.265: .Axes(xlValue).MaximumScale = 0.295
'            .HasTitle = True
'            .ChartTitle.Text = "Post FFL In Different Field"
'            .Legend.Position = xlLegendPositionBottom
'            .Legend.Font.Size = 6
'            .Legend.Height = 30
'        End With
'
'    Case "Ruby2_Pre_06"
'        With shp1.Chart
'            .SetSourceData Union(Sheets("Ruby2_Pre_06").Range("L1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("Ruby2_Pre_06").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("Ruby2_Pre_06").Columns("L:L").Range("a2")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
'        End With
'        k = 1
'        For Each ser In shp1.Chart.FullSeriesCollection
'            For Each pt In ser.Points
'                If ser.Values(k) > 2.5 Or ser.Values(k) < -2.5 Then
'                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
'                End If
'                k = k + 1
'            Next
'        Next
'        With shp2.Chart
'            .SetSourceData Union(Sheets("Ruby2_Pre_06").Range("J1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("Ruby2_Pre_06").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("Ruby2_Pre_06").Columns("J:J").Range("a2")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = -0.01: .Axes(xlValue).MaximumScale = 0
'        End With
'        With shp3.Chart
'            .SetSourceData Union(Sheets("Ruby2_Pre_06").Range("K1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("Ruby2_Pre_06").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("Ruby2_Pre_06").Columns("K:K").Range("a2")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = 45: .Axes(xlValue).MaximumScale = 55
'        End With
'        With shp4.Chart
'            .SetSourceData Sheets("Ruby2_Pre_06").Range("P1048576").End(xlUp)(-28, 1).Resize(30, 17)
'            .Axes(xlValue).MinimumScale = -3: .Axes(xlValue).MaximumScale = 3
'            .HasTitle = True
'            .ChartTitle.Text = "Monitor MTF"
'            .Legend.Position = xlLegendPositionBottom
'            .Legend.Font.Size = 6
'            .Legend.Height = 30
'        End With
'        arr1 = Sheets("Ruby2_Pre_06").Range("P2:AF2")
''        arr2 = Sheets("Ruby2_Pre_06").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
'        i = 1
'        For Each ser In shp4.Chart.SeriesCollection
'            ser.Name = arr1(1, i)
'            i = i + 1
'        Next

    Case "RADA-R2_Pre_10"
        With shp1.Chart
            .SetSourceData Union(Sheets("RADA-R2_Pre_10").Range("L1048576").End(xlUp)(-13, 1).Resize(15, 1), _
                Sheets("RADA-R2_Pre_10").Range("A1048576").End(xlUp)(-13, 1).Resize(15, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("RADA-R2_Pre_10").Columns("L:L").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 3 Or ser.Values(k) < -3 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("RADA-R2_Pre_10").Range("J1048576").End(xlUp)(-13, 1).Resize(15, 1), _
                Sheets("RADA-R2_Pre_10").Range("A1048576").End(xlUp)(-13, 1).Resize(15, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("RADA-R2_Pre_10").Columns("J:J").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("RADA-R2_Pre_10").Range("K1048576").End(xlUp)(-13, 1).Resize(15, 1), _
                Sheets("RADA-R2_Pre_10").Range("A1048576").End(xlUp)(-13, 1).Resize(15, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("RADA-R2_Pre_10").Columns("K:K").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = 25: .Axes(xlValue).MaximumScale = 30
        End With
        With shp4.Chart
            .SetSourceData Sheets("RADA-R2_Pre_10").Range("P1048576").End(xlUp)(-13, 1).Resize(15, 17)
            .Axes(xlValue).MinimumScale = -3: .Axes(xlValue).MaximumScale = 3
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With
        arr1 = Sheets("RADA-R2_Pre_10").Range("P2:AF2")
'        arr2 = Sheets("RASA_Pre_10").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
        i = 1
        For Each ser In shp4.Chart.SeriesCollection
            ser.Name = arr1(1, i)
            i = i + 1
        Next
        
'    Case "RASA_Pre_09"
'        With shp1.Chart
'            .SetSourceData Union(Sheets("RASA_Pre_09").Range("T1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("RASA_Pre_09").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("RASA_Pre_09").Columns("T:T").Range("a1")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
'        End With
'        k = 1
'        For Each ser In shp1.Chart.FullSeriesCollection
'            For Each pt In ser.Points
'                If ser.Values(k) > 0.003 Or ser.Values(k) < -0.003 Then
'                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
'                End If
'                k = k + 1
'            Next
'        Next
'        With shp2.Chart
'            .SetSourceData Union(Sheets("RASA_Pre_09").Range("AA1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("RASA_Pre_09").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("RASA_Pre_09").Columns("AA:AA").Range("a1")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
'        End With
'        With shp3.Chart
'            .SetSourceData Union(Sheets("RASA_Pre_09").Range("AB1048576").End(xlUp)(-28, 1).Resize(30, 1), _
'                Sheets("RASA_Pre_09").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
'            .HasLegend = False
'            .HasTitle = True
'            .ChartTitle.Text = Sheets("RASA_Pre_09").Columns("AB:AB").Range("a1")
'            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
'            .Axes(xlCategory).TickLabels.Font.Size = 6
'            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
'        End With
'        With shp4.Chart
'            .SetSourceData Sheets("RASA_Pre_09").Range("AD1048576").End(xlUp)(-28, 1).Resize(30, 17)
'            .Axes(xlValue).MinimumScale = -3: .Axes(xlValue).MaximumScale = 3
'            .HasTitle = True
'            .ChartTitle.Text = "Monitor MTF"
'            .Legend.Position = xlLegendPositionBottom
'            .Legend.Font.Size = 6
'            .Legend.Height = 30
'        End With
'        arr1 = Sheets("RASA_Pre_09").Range("AD1:AT1")
''        arr2 = Sheets("RASA_Pre_09").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
'        i = 1
'        For Each ser In shp4.Chart.SeriesCollection
'            ser.Name = arr1(1, i)
'            i = i + 1
'        Next
        
    Case "Garnet_Pre_12"
        With shp1.Chart
            .SetSourceData Union(Sheets("Garnet_Pre_12").Range("I1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Garnet_Pre_12").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Garnet_Pre_12").Columns("I:I").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.01: .Axes(xlValue).MaximumScale = 0.01
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 0.003 Or ser.Values(k) < -0.003 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("Garnet_Pre_12").Range("P1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Garnet_Pre_12").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Garnet_Pre_12").Columns("P:P").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("Garnet_Pre_12").Range("Q1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Garnet_Pre_12").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Garnet_Pre_12").Columns("Q:Q").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.01: .Axes(xlValue).MaximumScale = 0.01
        End With
        With shp4.Chart
            .SetSourceData Sheets("Garnet_Pre_12").Range("S1048576").End(xlUp)(-28, 1).Resize(30, 17)
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With
        arr1 = Sheets("Garnet_Pre_12").Range("S2:AI2")
'        arr2 = Sheets("Garnet_Pre_12").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
        i = 1
        For Each ser In shp4.Chart.SeriesCollection
            ser.Name = arr1(1, i)
            i = i + 1
        Next
        
    Case "Garnet_Pre_13"
        With shp1.Chart
            .SetSourceData Union(Sheets("Garnet_Pre_13").Range("T1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Garnet_Pre_13").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Garnet_Pre_13").Columns("T:T").Range("a1")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.01: .Axes(xlValue).MaximumScale = 0.01
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 0.003 Or ser.Values(k) < -0.003 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("Garnet_Pre_13").Range("AA1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Garnet_Pre_13").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Garnet_Pre_13").Columns("AA:AA").Range("a1")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("Garnet_Pre_13").Range("AB1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Garnet_Pre_13").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Garnet_Pre_13").Columns("AB:AB").Range("a1")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.01: .Axes(xlValue).MaximumScale = 0.01
        End With
        With shp4.Chart
            .SetSourceData Sheets("Garnet_Pre_13").Range("AD1048576").End(xlUp)(-28, 1).Resize(30, 17)
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With
        arr1 = Sheets("Garnet_Pre_13").Range("AD1:AT1")
'        arr2 = Sheets("Garnet_Pre_12").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
        i = 1
        For Each ser In shp4.Chart.SeriesCollection
            ser.Name = arr1(1, i)
            i = i + 1
        Next
        
        
    Case "Spinel_Pre_14"
        With shp1.Chart
            .SetSourceData Union(Sheets("Spinel_Pre_14").Range("I1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Spinel_Pre_14").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Spinel_Pre_14").Columns("I:I").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 0.002 Or ser.Values(k) < -0.002 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("Spinel_Pre_14").Range("P1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Spinel_Pre_14").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Spinel_Pre_14").Columns("P:P").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("Spinel_Pre_14").Range("Q1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Spinel_Pre_14").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Spinel_Pre_14").Columns("Q:Q").Range("a2")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        With shp4.Chart
            .SetSourceData Sheets("Spinel_Pre_14").Range("S1048576").End(xlUp)(-28, 1).Resize(30, 17)
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With
        arr1 = Sheets("Spinel_Pre_14").Range("S2:AI2")
'        arr2 = Sheets("Garnet_Pre_12").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
        i = 1
        For Each ser In shp4.Chart.SeriesCollection
            ser.Name = arr1(1, i)
            i = i + 1
        Next
        
    Case "Ammolite_Pre_04"
        With shp1.Chart
            .SetSourceData Union(Sheets("Ammolite_Pre_04").Range("T1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Ammolite_Pre_04").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Ammolite_Pre_04").Columns("T:T").Range("a1")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        k = 1
        For Each ser In shp1.Chart.FullSeriesCollection
            For Each pt In ser.Points
                If ser.Values(k) > 0.003 Or ser.Values(k) < -0.003 Then
                    pt.Format.Fill.ForeColor.RGB = vbRed                 'RGB(255, 0, 0)
                End If
                k = k + 1
            Next
        Next
        With shp2.Chart
            .SetSourceData Union(Sheets("Ammolite_Pre_04").Range("AA1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Ammolite_Pre_04").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Ammolite_Pre_04").Columns("AA:AA").Range("a1")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        With shp3.Chart
            .SetSourceData Union(Sheets("Ammolite_Pre_04").Range("AB1048576").End(xlUp)(-28, 1).Resize(30, 1), _
                Sheets("Ammolite_Pre_04").Range("B1048576").End(xlUp)(-28, 1).Resize(30, 1))
            .HasLegend = False
            .HasTitle = True
            .ChartTitle.Text = Sheets("Ammolite_Pre_04").Columns("AB:AB").Range("a1")
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = -0.005: .Axes(xlValue).MaximumScale = 0.005
        End With
        With shp4.Chart
            Set ws = Sheets("Ammolite_Pre_04")
            n = ws.Rows(1048576).End(xlUp).Row: m = n - 29
            .SetSourceData Union(ws.Range("AD1:AE1"), ws.Range("AD" & m & ":AE" & n), ws.Range("AI1"), _
                ws.Range("AI" & m & ":AI" & n), ws.Range("AM1:AT1"), ws.Range("AM" & m & ":AT" & n))
            .Axes(xlValue).MinimumScale = -5: .Axes(xlValue).MaximumScale = 5
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
        End With

'        arr2 = Sheets("Ammolite_Pre_04").Range("A1048576").End(xlUp)(-28, 1).Resize(30, 1)
'        i = 1
'        For Each ser In shp4.Chart.SeriesCollection
'            ser.Name = arr1(1, i)
'            i = i + 1
'        Next

    Case "7690_01"
        shp1.Delete: shp2.Delete: shp3.Delete
        With shp4.Chart
            .SetSourceData Union(Sheets("7690_01").Range("E1048576").End(xlUp)(-28, 1).Resize(30, 5), Sheets("7690_01").Range("E1:I1"))
            .HasTitle = True
            .ChartTitle.Text = "Monitor MTF"
            .Legend.Position = xlLegendPositionBottom
            .Legend.Font.Size = 6
            .Legend.Height = 30
            .Axes(xlCategory).CategoryType = xlCategoryScale: .Axes(xlCategory).TickLabelSpacing = 1
            .Axes(xlCategory).TickLabels.Font.Size = 6
            .Axes(xlValue).MinimumScale = 44: .Axes(xlValue).MaximumScale = 56
        End With

End Select
Application.DisplayAlerts = True
End Sub



''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
'代码块3:这部分代码利用Listbox GotFocus事件切换需要绘制图表的数据源绘制新的图表
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
Private Sub ListBox1_GotFocus()
Dim ar_item
Me.ListBox1.Clear
ar_item = Array("Iolite_Pre_05", "Iolite_Pre_08", "Iolite_Post_11", "Quartz_Pre_03", "RADA-R2_Post_02", "RADA-R2_Pre_10", _
    "Garnet_Pre_12", "Garnet_Pre_13", "Spinel_Pre_14", "Ammolite_Pre_04", "7690_01")
    For x = 0 To UBound(ar_item)
        Me.ListBox1.AddItem ar_item(x)
    Next
'With Me.ListBox1
'    .AddItem "Iolite_Pre_03"
'    .AddItem "Iolite_Pre_05"
'    .AddItem "Iolite_Pre_08"
'    .AddItem "Iolite_Post_02"
'    .AddItem "Iolite_Post_11"
'    .AddItem "Ruby2_Post_16"
'    .AddItem "Ruby2_Pre_06"
'    .AddItem "RASA_Pre_10"
'    .AddItem "RASA_Pre_09"
'    .AddItem "Garnet_Pre_12"
'    .AddItem "Spinel_Pre_14"
'    .AddItem "Ammolite_Pre_04"
'    .AddItem "7690_01"
'End With
End Sub

利用上述代码形成动态图表如下图所示,按钮可以更新数据源,利用滚动条可以动态选择想要查看的数据图表,至于横坐标的日期区间则可以代码动态选择数据源实现,纵坐标的范围则可以代码控制图标坐标轴区间实现。

值得注意的是,代码块1的代码可以写在Excel子模块里面,但是模块2,3的代码则必须写在工作表里面,这是因为触发事件的对象是工作表。
在这里插入图片描述
除此以外,代码变量的声名应该符合规则,或者取消代码强制变量声明;以上代码可以完成动态绘制多个数据的图表,其中,对于图表属性的定义以及触发事件的控制值得参考。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1524002.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

便利店小程序有哪些功能

​便利店小程序为附近的住户提供小程序在线购物的服务。用户只需要打开小程序&#xff0c;就可以购买需要的商品&#xff0c;可以选择自取或者配送。整个过程非常简单快速。下面具体介绍便利店小程序的功能。 1. **商品展示**&#xff1a;展示便利店的商品信息&#xff0c;包括…

【C++刷题】优选算法——动态规划第一辑

1.状态表示是什么&#xff1f;简答理解是dp表里的值所表示的含义怎么来的&#xff1f;题目要求经验题目要求分析问题的过程中&#xff0c;发现重复子问题 2.状态转移方程dp[i]......细节问题&#xff1a;3.初始化控制填表的时候不越界4.填表顺序控制在填写当前状态的时候&#…

windows下修改mysql的max_allowed_packet的值

1)C:\Program Files\MySQL\MySQL Server 5.7 在MySQL 的安装目录下添加my.ini文件&#xff0c;同时添加空的data文件 2&#xff09;my.ini文件内容如下&#xff0c; [mysqld] port 3306 basedirC:\Program Files\MySQL\MySQL Server 5.7 datadirC:\Program Files\MySQL\MySQ…

软考78-上午题-【面向对象技术3-设计模式】-结构型设计模式01

一、适配器模式 1-1、意图 个类的接口转换成客户希望的另外一个接口。 Adapter 模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。 1-2、结构 适配器模式分为&#xff1a; 1、适配器类模式&#xff1b; 2、适配器对象模式 类适配器使用多重继承对一个接口与另…

java基础(6) IO[下] 线程(补充) XML Servlet

输出流 OutputStream OutputStream是Java标准库提供的最基本的输出流。 和InputStream类似&#xff0c;OutputStream也是抽象类&#xff0c;它是所有输出流的超类。这个抽象类定义的一个最重要的方法就是void write(int b) public abstract void write(int b) throws IOExcep…

html--宠物

文章目录 htmljscss html <!DOCTYPE html> <html lang"en" > <head><meta charset"UTF-8"><title>CodePen - Spaceworm</title><script> window.requestAnimFrame (function() {return (window.requestAnimat…

Javascript抓取京东、淘宝商品数据(商品采集商品详情图片抓取)

之前用的方法&#xff1a; let temp []var lists $(#J_goodsList li.gl-item)$.each(lists,function(idx,item){ temp.push({ id:$(item).data(sku), goods_img:$(item).find(img).attr(src), goods_name:$(item).find(.p-name em).text(), market_price:$(item).fi…

2024 年(第 12 届)“泰迪杯”数据挖掘挑战赛——B 题:基于多模态特征融合的图像文本检索完整思路与源代码分享

一、问题背景 随着近年来智能终端设备和多媒体社交网络平台的飞速发展&#xff0c;多媒体数据呈现海量增长 的趋势&#xff0c;使当今主流的社交网络平台充斥着海量的文本、图像等多模态媒体数据&#xff0c;也使得人 们对不同模态数据之间互相检索的需求不断增加。有效的信…

洛谷P8972 『GROI-R1』 一切都已过去(树上前缀和+运算符重载)

『GROI-R1』 一切都已过去 题目背景 悦关上窗&#xff0c;拉上帘布。 果然还是想不起来啊。 隐约记得曾和什么人一起做过这样的事。 仰面躺下&#xff0c;手执一只木笺。 「究竟如何&#xff0c;才能拥有“过去”啊……」 她闭上双眼。 「6 岁前的记忆……究竟如何才能…

ConsiStory:Training-Free的主体一致性生成

Overview 一、总览二、PPT详解 ConsiStory 一、总览 题目&#xff1a; Training-Free Consistent Text-to-Image Generation 机构&#xff1a;NVIDIA, Tel-Aviv University 论文&#xff1a;https://arxiv.org/pdf/2402.03286.pdf 代码&#xff1a;https://consistory-paper.g…

Python自动获取指定上市公司的所有财务数据(资产负债表,利润表,现金流量表)

案例背景 很多经管类同学找财务数据都很困难&#xff0c;去找一个个查找特定的公司&#xff0c;然后又要去同花顺或者东方财富网一年一年的去查看报表&#xff0c;一年一年的数据一个个填入...太慢了。 tushare能获取金融数据的接口&#xff0c;他有资产负债表&#xff0c;利…

idea warning:java源值已过时将在未来所有发行版中删除

在idea中运行maven项目 如果出现idea warning:java源值已过时将在未来所有发行版中删除&#xff0c;详见如下截图所示&#xff1a; 注意&#xff1a;jdk8 要解决这个警告需要设置3个地方 首先打开File->Project Structure中的Project&#xff0c;将SDK和language level都设…

Java学习笔记(15)

JDK7前时间相关类 Date时间类 Simpledateformat Format 格式化 Parse 解析 默认格式 指定格式 EE&#xff1a;表示周几 Parse&#xff1a;把字符串时间转成date对象 注意&#xff1a;创建对象的格式要和字符串的格式一样 Calendar日历类 不能创建对象 Getinstance 获取当…

Python笔记|字符串合并、切片、索引

一、合并 字符串可以用 合并&#xff08;粘到一起&#xff09;&#xff0c;也可以用 * 重复&#xff1a; >>> 3 * un ium unununium 相邻的两个或多个字符串字面值&#xff08;引号标注的字符&#xff09;会自动合并&#xff1a; >>> Py thon Python …

蓝桥杯每日一题 走迷宫bfs 超超详细解释!!!

昨天学习了bfs的基本概念&#xff0c;今天来做一道经典习题练练手吧&#xff01; bfs常用的两类题型 1.从A出发是否存在到达B的路径(dfs也可) 2.从A出发到B的最短路径&#xff08;数小:<20才能用dfs&#xff09; 遗留的那个问题的答案- 题目&#xff1a;走迷宫 答案&…

【Java刷题篇】串联所有单词的子串

这里写目录标题 &#x1f4c3;1.题目&#x1f4dc;2.分析题目&#x1f4dc;3.算法原理&#x1f9e0;4.思路叙述✍1.进窗口✍2.判断有效个数✍3.维护窗口✍4.出窗口 &#x1f4a5;5.完整代码 &#x1f4c3;1.题目 力扣链接: 串联所有单词的子串 &#x1f4dc;2.分析题目 阅…

力扣L14--- 415.字符串相加(JAVA版)-2024年3月17日

1.题目 2.知识点 注1&#xff1a;你可以使用Integer.parseInt()或Double.parseDouble()等方法将字符串转换为整数或浮点数。 public class Main {public static void main(String[] args) {String str "123";int num Integer.parseInt(str);System.out.println(…

如何在Mac中删除照片?这里有详细步骤

前言 本文介绍如何从Mac中删除照片,以释放硬盘空间或更好地组织文件和文件夹。 如何使用废纸篓删除Mac上的图片 在Mac上删除图片的最简单方法之一是使用废纸篓功能。学习只需几秒钟。下面是如何删除单个图片以及如何在Mac上删除多个图片,以及一些关键和有用的提示,以使该…

2023全球国际专利申请数量公布:华为遥遥领先三星、高通、苹果~

华为、三星和高通在2023年的国际专利申请数量上位居前三甲&#xff0c;其中来自中国的公司大幅度超越韩国和美国的高科技竞争对手。世界知识产权组织&#xff08;WIPO&#xff09;最新发布的数据显示&#xff0c;即使面临美国严厉制裁严重影响其在全球市场的运作能力&#xff0…

HTML静态网页成品作业(HTML+CSS)——家乡广州介绍设计制作(5个页面)

&#x1f389;不定期分享源码&#xff0c;关注不丢失哦 文章目录 一、作品介绍二、作品演示三、代码目录四、网站代码HTML部分代码 五、源码获取 一、作品介绍 &#x1f3f7;️本套采用HTMLCSS&#xff0c;未使用Javacsript代码&#xff0c;共有5个页面。 二、作品演示 三、代…