tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,834
- Office Version
- 365
- 2019
- Platform
- Windows
I have a chart on a worksheet and two associated controls.
One is a spin button that controls the starting point of my data. The other is a value in a cell that specifies the range of the data to plot the chart.
For example, if the Spin button value is 20 and the range of data value is 30, that means the chart starts at point 20 and contains values up to point 49.
The code below works fine:
Standard Module:
In wksData:
What I want to know is how can I turn it into an object oriented way?
Obviously I'll need some classes but I cannot see what I should put into a standard module and what should be in a class.
Any help greatly appreciated.
One is a spin button that controls the starting point of my data. The other is a value in a cell that specifies the range of the data to plot the chart.
For example, if the Spin button value is 20 and the range of data value is 30, that means the chart starts at point 20 and contains values up to point 49.
The code below works fine:
Standard Module:
Code:
Option Explicit
Sub Macro1()
Dim Interval As Long
Interval = wksData.Cells(19, 6).Value
Dim DataStart As Long
DataStart = wksData.Cells(19, 13).Value
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).XValues = Range(wksData.Cells(DataStart + 1, 1), wksData.Cells(DataStart + Interval, 1))
ActiveChart.FullSeriesCollection(1).Values = Range(wksData.Cells(DataStart + 1, 2), wksData.Cells(DataStart + Interval, 2))
End Sub
In wksData:
Code:
Private Sub SpinButton1_Change()
Call Module1.Macro1
End Sub
What I want to know is how can I turn it into an object oriented way?
Obviously I'll need some classes but I cannot see what I should put into a standard module and what should be in a class.
Any help greatly appreciated.