BiochemBoi95
New Member
- Joined
- Jan 22, 2020
- Messages
- 20
- Office Version
- 365
- 2016
- Platform
- Windows
- Web
I am getting an error trying to set the titles for the x and y axis of a chart using a macro made by the macro recorder. I am getting a run time error 91 on line 59 which I have highligted red. Any help is greatly appreciated.
Rich (BB code):
Sub GraphMaker()
'
' GraphMaker Macro
'
' Keyboard Shortcut: Ctrl+Shift+G
'
ActiveWindow.SmallScroll Down:=12
ActiveCell.Offset(32, 6).Range("A1").Select
ActiveCell.FormulaR1C1 = "0"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "5"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "6"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "7"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveWindow.SmallScroll Down:=-15
ActiveCell.Offset(-40, -6).Range("A1").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=24
ActiveCell.Offset(35, 7).Range("A1").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-21
ActiveCell.Offset(-31, -7).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=21
ActiveCell.Offset(32, 7).Range("A1").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-15
ActiveCell.Offset(-33, -7).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=15
ActiveCell.Offset(34, 7).Range("A1").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-18
ActiveCell.Offset(-35, -7).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=21
ActiveCell.Offset(36, 7).Range("A1").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-18
ActiveCell.Offset(-37, -7).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=21
ActiveCell.Offset(38, 7).Range("A1").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-6
ActiveCell.Offset(-3, -1).Range("A1:B4").Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterSmooth).Select
ActiveChart.SetSourceData Source:=Range("Test!$K$561:$L$564")
ActiveSheet.Shapes("Chart 14").IncrementLeft 152.25
ActiveSheet.Shapes("Chart 14").IncrementTop 155.25
ActiveWindow.SmallScroll Down:=12
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Round Number"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Round Number"
With Selection.Format.TextFrame2.TextRange.Characters(1, 12).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 12).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Nucleotide A %"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Nucleotide A %"
With Selection.Format.TextFrame2.TextRange.Characters(1, 14).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 10).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
With Selection.Format.TextFrame2.TextRange.Characters(11, 4).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
End Sub
Last edited by a moderator: