I am trying to create a VBA loop to build line graphs. I want the loop to look at a reference tab and create each graph on a new named tab accordingly to my list. I have pasted my code below (I am VBA novice--this is what I have been able to string together via MANY web searches). I have attached a dummy file, including what I want the graphs to look like.
Sub GrphLoop()
'
' GrphLoop Macro
'
Dim sheet_name As Range
Dim graph_name As Range
For Each sheet_name In Sheets("REFACCTS").Range("A:A")
For Each graph_name In Sheets("REFACCTS").Range("B:B")
If sheet_name.Value = "" Then
Exit For
Else
Sheets(sheet_name.Value).Select
Range("B:B,F:K").Select
Sheets(sheet_name.Value).Select
ActiveChart.SetSourceData Source:=Range("$B:$B,$F:$K")
Charts.Add
ActiveChart.ChartType = xlLine
ActiveSheet.Name = graph_name.Value
Sheets(graph_name.Value).Move Before:=Sheets(3)
ActiveChart.ChartArea.Select
ActiveChart.PlotArea.Select
Selection.Height = 344.64
Selection.Top = 96.102
ActiveChart.Legend.Select
Selection.Delete
Cells.Select
With Selection.Font
.Name = "Frutiger 55 Roman"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Frutiger 55 Roman"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.ThemeColor = xlThemeColorAccent1
.TintAndShade = -0.249977111117893
End With
Range("A1").Select
ActiveCell.FormulaR1C1 = sheet_name
Range("A2").Select
ActiveCell.FormulaR1C1 = "CUMULATIVE GROWTH OF CAPITAL SINCE INCEPTION"
Range("A3").Select
ActiveCell.FormulaR1C1 = "NET OF FEES AS OF:"
Range("D3").Select
ActiveCell.FormulaR1C1 = _
"=UPPER(TEXT(INDEX((sheet_name.value)C[-2],COUNTA(sheet_name.value)C[-2]),1),""mmmm d, yyyy""))"
Dim mySrs As Series
Dim nPts As Long
For Each mySrs In ActiveChart.SeriesCollection
With mySrs
nPts = .Points.Count
mySrs.Points(nPts).ApplyDataLabels _
Type:=xlDataLabelsShowValue, _
AutoText:=True, LegendKey:=False
mySrs.Points(nPts).DataLabel.Text = mySrs.Name
End With
End If
Next sheet_name
Bookmarks