I'm trying to figure out how to add in Axis titles in my code below
Most of this was trial and error via Macro Recorder but I'm stumped after the .SetElement part as I don't think there is an easy way to do it when I'm using Chart as a variable type? I know in the Macro recorder it will do something like this:
Code:
Sub CreateChart()Dim rng As Range
Dim cht As ChartObject
Dim ws As Worksheet, ws2 As Worksheet
Set ws = Worksheets("Daily Data Transfer")
Set ws2 = Worksheets("Daily Report")
Set rng = ws.Range("B1:C31,G1:G31,Q1:R31")
Set cht = ws2.ChartObjects.Add(Left:=50, Width:=283.5, Top:=50, Height:=170)
With cht.Chart
.HasTitle = True
.ChartTitle.Text = "pH/Temp°C vs Dosage mg/L"
.SetSourceData Source:=rng
.ChartType = xlLine
.SetElement (msoElementPrimaryValueAxisShow)
.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
End With
End Sub
Most of this was trial and error via Macro Recorder but I'm stumped after the .SetElement part as I don't think there is an easy way to do it when I'm using Chart as a variable type? I know in the Macro recorder it will do something like this:
Code:
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "pH"