HI
Try the following codes
Sub trans()
Dim a, x, y, c, d As Integer
Dim b As String
d = 1
a = InputBox("Enter the value of n")
x = Cells(Rows.Count, 1).End(xlUp).Row
For c = 1 To x Step a
Cells(d, 24) = Cells(c, 1)
Cells(d, 25) = Cells(c, 2)
Cells(d, 26) = Cells(c, 3)
d = d + 1
Next c
y = Cells(Rows.Count, 24).End(xlUp).Row
b = "X1:z" & y
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Worksheets("energyoutput").Range(b), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="energyoutput"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub
Run the macro. Enter the value of N. it will collate all nth values of col A to C in col X to Z and draws a Line graph
Ravi
Bookmarks