图表多系列评估列值

时间:2013-01-26 10:14:46

标签: macros

我对宏很新,并且一直在使用像SQL这样的简单语言。 任何帮助将不胜感激!!

我很确定我的代码看起来很有趣和有趣〜

目标:

  1. GRAPH COLUMN(H)AS X,COLUMN(I)AS Y
  2. 评估列(J)作为设置4个不同范围的行范围的值
  3. RANGE1< = 5,5< RANGE2< = 10,10< RANGE3< = 15,RANGE4> 15
  4. 针对相应范围返回散射图上的不同系列
  5. 以下是我已经尝试过的宏:

    Private Sub GRAPH()
    
    Application.ScreenUpdating = False
    FINALROW = Sheet1.Range("A65536").End(xlUp).Row
    RowRange = Sheet1.Range(J2, "J" & FINALROW).Row
    
    If RowRange <= 5 Then
    ROW5 = WorksheetFunction.Max(Rows(H2, "H" & FINALROW)).Row
    End If
    
    If RowRange <= 10 Then
    ROW10 = WorksheetFunction.Max(Rows(H2, "H" & FINALROW)).Row
    End If
    
    If RowRange <= 15 Then
    ROW15 = WorksheetFunction.Max(Rows(H2, "H" & FINALROW)).Row
    End If
    
    sheetname = ActiveSheet.Name
    
    Charts.Add
    ActiveChart.ChartType = xlXYScatterLinesNoMarkers
    ActiveChart.SetSourceData Source:=Columns("H:I")
    
    ActiveChart.SeriesCollection(1).XValues = Range("H" & ROW5, lastcell2)
    ActiveChart.SeriesCollection(2).XValues = Range("H" & ROW10, lastcell2)
    ActiveChart.SeriesCollection(3).XValues = Range("H" & ROW15, lastcell2)
    ActiveChart.SeriesCollection(4).XValues = Range("H" & FINALROW, lastcell2)
    
    ActiveChart.SeriesCollection(1).YValues = Range("I" & ROW5, lastcell2)
    ActiveChart.SeriesCollection(2).YValues = Range("I" & ROW10, lastcell2)
    ActiveChart.SeriesCollection(3).YValues = Range("I" & ROW15, lastcell2)
    ActiveChart.SeriesCollection(4).YValues = Range("I" & FINALROW, lastcell2)
    
    End Sub
    

0 个答案:

没有答案