Boogerbut74
New Member
- Joined
- Oct 17, 2022
- Messages
- 26
- Office Version
- 365
- Platform
- Windows
Right now im trying to set the variable rng as cell H39 (H39 will be populated with a capital letter of a column) in my reference sheet and then have rng defing the range in the variable Graph Range.
VBA Code:
Sub Test_7()
Dim lastrow As Integer
Dim GraphRange As Range
Dim rng As Range
Worksheets("Reference").rng = Range("H39")
lastrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 10).End(xlUp).Row
'set chart data range (including series names)
Set GraphRange = ActiveSheet.Range("D10:" & rng & lastrow)
'Create a chart
Set cht = ActiveSheet.ChartObjects.Add( _
Left:=ActiveCell.Left, _
Width:=450, _
Top:=ActiveCell.Top, _
Height:=250)
'Give chart some data
cht.Chart.SetSourceData Source:=GraphRange
'Determine the chart type
cht.Chart.ChartType = xlXYScatterSmooth
'edits chart detailes
cht.Chart.Axes(xlCategory).MinimumScale = 0
cht.Chart.Axes(xlCategory).MaximumScale = 100
cht.Chart.Axes(xlValue).MinimumScale = 115
cht.Chart.Axes(xlValue).MaximumScale = 140
cht.Chart.Legend.Position = xlLegendPositionBottom
cht.Select
ActiveChart.FullSeriesCollection(1).Delete
End Sub
Sub Test_6()
Dim lastrow As Integer
Dim GraphRange As Range
lastrow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 10).End(xlUp).Row
'set chart data range (including series names)
Set GraphRange = ActiveSheet.Range("D10:T" & lastrow)
'Create a chart
Set cht = ActiveSheet.ChartObjects.Add( _
Left:=ActiveCell.Left, _
Width:=450, _
Top:=ActiveCell.Top, _
Height:=250)
'Give chart some data
cht.Chart.SetSourceData Source:=GraphRange
'Determine the chart type
cht.Chart.ChartType = xlXYScatterSmooth
'edits chart detailes
cht.Chart.Axes(xlCategory).MinimumScale = 0
cht.Chart.Axes(xlCategory).MaximumScale = 100
cht.Chart.Axes(xlValue).MinimumScale = 115
cht.Chart.Axes(xlValue).MaximumScale = 140
cht.Chart.Legend.Position = xlLegendPositionBottom
End Sub