Sub VedothiZFW()
'
' Vedothi ZFW Macro
'
'
'
'Ve do thi Z~F~W
Dim Z, F, W, Td, Qd, Qx As Range
Dim Tdt, Qdt, Qxdt, Wdt, Zdt As Range
Dim Fn As WorksheetFunction
Set Fn = Application.WorksheetFunction
'Ve do thi
Charts.Add
'Chon kieu do thi Scatter
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
'Ve do thi F~Z
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=Dauvao!F" 'Lỗi ở chỗ này
ActiveChart.SeriesCollection(1).Values = "=Dauvao!Z" 'Lỗi ở chỗ này
ActiveChart.SeriesCollection(1).Name = "F"
ActiveChart.Location Where:=xlLocationAsObject, Name:="ChartZFW"
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
'Ve do thi W~Z
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).XValues = "=Dauvao!W" 'Lỗi ở chỗ này
ActiveChart.SeriesCollection(2).Values = "=Dauvao!Z" 'Lỗi ở chỗ này
ActiveChart.SeriesCollection(2).Name = "W"
' Hien truc toa do cho chuoi du lieu thu 2 la W
ActiveChart.SeriesCollection(2).Select
ActiveChart.SeriesCollection(2).AxisGroup = 2
ActiveChart.ChartArea.Select
'Them truc toa do cho chuoi du lieu thu 2
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlCategory, xlSecondary) = True
.HasAxis(xlValue, xlPrimary) = True
.HasAxis(xlValue, xlSecondary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
ActiveChart.Axes(xlCategory, xlSecondary).CategoryType = xlAutomatic
ActiveChart.Axes(xlCategory, xlSecondary).Select
'ActiveWindow.Visible = False
' Dao chieu cot du lieu cho truc thu 2
With ActiveChart.Axes(xlCategory, xlSecondary)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = True
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
' Dinh dang khoang cach gia tri cot du lieu theo truc tung Z ~F
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = Fn.Min(Z) 'Lỗi ở chỗ này
.MaximumScale = Fn.Max(Z) 'Lỗi ở chỗ này
.MinorUnitIsAuto = True
.MajorUnit = 10
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
' Dinh dang khoang cach gia tri cot du lieu theo truc tung Z ~W
ActiveChart.Axes(xlValue, xlSecondary).Select
With ActiveChart.Axes(xlValue, xlSecondary)
.MinimumScale = Fn.Min(Z) 'Lỗi ở chỗ này
.MaximumScale = Fn.Max(Z) 'Lỗi ở chỗ này
.MinorUnitIsAuto = True
.MajorUnit = 10
.Crosses = xlMaximum
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
'ActiveWindow.Visible = False
' Dinh dang lai co font chu cho tung truc toa do
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
' Doi lai font nen cho do thi thanh mau trang
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Interior.ColorIndex = xlNone
' Dinh vi vi tri bieu doi
' Dinh chieu rong'
ActiveSheet.ChartObjects(1).Width = 350
' Dinh chieu cao'
ActiveSheet.ChartObjects(1).Height = 220
'Dinh vi tri canh trai bang voi canh trai cot B (cot 2)'
ActiveSheet.ChartObjects(1).Left = Cells(1, 2).Left
'Dinh vi tri canh tren bang voi canh tren dong 5'
ActiveSheet.ChartObjects(1).Top = Cells(5, 1).Top
End Sub