I am trying loop the scatter plot over columns using Excel VBA, but did get idea how to do it.
Here is a dummy data I produced by filling Y series with RAND() function and the figure shows a sample chart I produced.
Here is associated codes:
Sub multichart()
Range("A1:B21").Select
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:B21"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Y1"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveSheet.Shapes("Chart 6").ScaleHeight 0.61, msoFalse, msoScaleFromTopLeft
ActiveChart.PlotArea.Select
Selection.Top = 1
Selection.Height = 106
Selection.Height = 113
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
End Sub
I want to loop this process to create N graphs (where N is number of Y columns in any sheet), means vary from sheet to sheet. Also plots will be appended one after another. Y limits and X limit are intended to be same in all plots for comparison. The output look something like (just showing 4 variables for example):
Sorry if this a basic question as I am Excel VBA guest.