Yes you are correct, it is a typo but it still doesn't like the line
and.... its the simplest things that you cant see in the forest. Corrected the Range("A2").valueset data_rng = Range("A2").Value
and now it says
the first line is incorrect as its undefined
Sub Create_Dynamic_Chart() Dim sht As Worksheet Dim chrt As Chart Dim data_rng As Range Set sht = Sheet1 Set data_rng = Worksheet("Chart").Range("A2").Value Select Case dRange Case Range("A2").Value = "Charleville" data_rng = tblCharlevilleTemps Case Range("A2").Value = "Dalby" data_rng = tblDalbyTemps Case Range("A2").Value = "Toowoomba" data_rng = tblToowoombaTemps Case Range("A2").Value = "Warwick" data_rng = tblWarwickTemps End Select Set chrt = sht.Shapes.AddChart2(Style:=-1, Width:=900, Height:=200, Left:=Range("G2").Left, Top:=Range("G2").Top).Chart With chrt .SetSourceData Source:=data_rng .ChartType = xlLineStacked .ChartTitle.Text = Range("A2").Value & " Min & Max Temps" .SetElement msoElementDataLabelOutSideEnd .SetElement msoElementPrimaryValueGridLinesMajor .SetElement msoElementLegendBottom .SetElement msoElementPrimaryCatergoryAxixTitleBelowValue End With End Sub





Reply With Quote
