Good Evening,
Any help appreciated in advance.
I'm looking to generate simple charts using data decided by the user inputting chosen dates from a userfrom.
The dates are along e2:av2 so the user can select from that array (they will decide on charttype and dataset, but I'll come to that when I can do this)
I need the chart to then use the selected dates range of data. How do I determine the range so that the chart can use those cells??
Private Sub CommandButton2_Click()
'Dim charttype As String
'Dim dataset As String
Dim dat1 As String
Dim dat2 As String
Dim r As Range
Dim cec1 As Range
Dim cec2 As Range
'charttype = ComboBox1.Value
'dataset = ComboBox2.Value
dat1 = ComboBox3.Value
dat2 = ComboBox4.Value
Set r = Range("e2:av2")
For Each cell In r
If cell.Value = dat1 Then
cell.Activate
Set cec1 = ActiveCell
End If
Next
For Each cell In r
If cell.Value = dat2 Then
cell.Offset(1, 0).Activate
Set cec2 = ActiveCell
End If
Next
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.SetSourceData Source:=Range("Budget!???:???")
End Sub
Any help appreciated in advance.
I'm looking to generate simple charts using data decided by the user inputting chosen dates from a userfrom.
The dates are along e2:av2 so the user can select from that array (they will decide on charttype and dataset, but I'll come to that when I can do this)
I need the chart to then use the selected dates range of data. How do I determine the range so that the chart can use those cells??
Private Sub CommandButton2_Click()
'Dim charttype As String
'Dim dataset As String
Dim dat1 As String
Dim dat2 As String
Dim r As Range
Dim cec1 As Range
Dim cec2 As Range
'charttype = ComboBox1.Value
'dataset = ComboBox2.Value
dat1 = ComboBox3.Value
dat2 = ComboBox4.Value
Set r = Range("e2:av2")
For Each cell In r
If cell.Value = dat1 Then
cell.Activate
Set cec1 = ActiveCell
End If
Next
For Each cell In r
If cell.Value = dat2 Then
cell.Offset(1, 0).Activate
Set cec2 = ActiveCell
End If
Next
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.SetSourceData Source:=Range("Budget!???:???")
End Sub