I've got a macro that creates a graph based on information on the first three columns of the spreadsheet. It works just fine, but now I'm stuck on a tiny, futile detail that refuses to budge.
The code's a bit long, but bear with me.
Everything works except for the part I commented out. I can remove the comments and the code will still run just fine, it just ignores that batch of code, for whatever reason. Also, the only part of that block that really matters is the .TickLabelPosition = xlHigh part, but I tried to see if the rest was necessary to make it work. It wasn't.
The code's a bit long, but bear with me.
Code:
Sub Graph()
Application.ScreenUpdating = False
With ActiveWorkbook.Worksheets(2)
ActiveWorkbook.Worksheets(2).Activate
Range("B2").End(xlDown).Activate
Set Rng = Range("B2", ActiveCell)
Set LstCl = ActiveCell
Sname = Range("A1").Parent.Name
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Rng, PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=Sname
ActiveChart.HasTitle = False
With ActiveChart
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "STEP"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "SIGY"
.Axes(xlValue).ReversePlotOrder = True
'.Axes(xlCategory).Select
'With Selection.Border
' .Weight = xlHairline
' .LineStyle = xlAutomatic
'End With
'With Selection
' .MajorTickMark = xlOutside
' .MinorTickMark = xlNone
' .TickLabelPosition = xlHigh
'End With
.HasLegend = False
.HasDataTable = False
.PlotArea.Select
For i = 2 To LstCl.Row
.SeriesCollection.NewSeries
.SeriesCollection(i).Select
With Selection
.ChartType = xlXYScatter
.XValues = "='" & Sname & "'!R" & i & "C1"
.Values = "='" & Sname & "'!R" & i & "C2"
.Name = "='" & Sname & "'!R" & i & "C3"
With .Border
.Weight = xlHairline
.LineStyle = xlNone
End With
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 5
.Shadow = False
.ApplyDataLabels AutoText:=True, LegendKey:= _
False, ShowSeriesName:=True, ShowCategoryName:=False, ShowValue:=False, _
ShowPercentage:=False, ShowBubbleSize:=False
With .DataLabels
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ReadingOrder = xlContext
.Position = xlLabelPositionAbove
.Orientation = xlHorizontal
.Font.Size = 8
End With
End With
Next i
.SeriesCollection(1).ChartType = xlLineMarkers
End With
Set ChOb = ActiveChart.Parent
ChOb.Height = Range(.Cells(1, 4), .Cells(LstCl.Row, 3 + Application.WorksheetFunction.Round(LstCl.Row / 2, 0))).Height
ChOb.Width = Range(.Cells(1, 4), .Cells(LstCl.Row, 3 + Application.WorksheetFunction.Round(LstCl.Row / 2, 0))).Width
ChOb.Top = Range(.Cells(1, 4), .Cells(LstCl.Row, 3 + Application.WorksheetFunction.Round(LstCl.Row / 2, 0))).Top
ChOb.Left = Range(.Cells(1, 4), .Cells(LstCl.Row, 3 + Application.WorksheetFunction.Round(LstCl.Row / 2, 0))).Left
End With
Worksheets(1).Activate
Application.ScreenUpdating = True
End Sub
Everything works except for the part I commented out. I can remove the comments and the code will still run just fine, it just ignores that batch of code, for whatever reason. Also, the only part of that block that really matters is the .TickLabelPosition = xlHigh part, but I tried to see if the rest was necessary to make it work. It wasn't.